mirror of
https://github.com/markwylde/claude-code-gitea-action.git
synced 2026-02-20 02:22:49 +08:00
Attempt to make this work
This commit is contained in:
@@ -119,7 +119,7 @@ export async function setupBranch(
|
|||||||
|
|
||||||
console.log(`Current SHA: ${currentSHA}`);
|
console.log(`Current SHA: ${currentSHA}`);
|
||||||
|
|
||||||
// Create branch - try GitHub API first, fallback to Gitea API
|
// Create branch - try GitHub API first, fallback to Git CLI
|
||||||
try {
|
try {
|
||||||
await octokits.rest.git.createRef({
|
await octokits.rest.git.createRef({
|
||||||
owner,
|
owner,
|
||||||
@@ -127,24 +127,20 @@ export async function setupBranch(
|
|||||||
ref: `refs/heads/${newBranch}`,
|
ref: `refs/heads/${newBranch}`,
|
||||||
sha: currentSHA,
|
sha: currentSHA,
|
||||||
});
|
});
|
||||||
} catch (createRefError: any) {
|
|
||||||
// If git/refs creation fails (like in Gitea), use the branches endpoint
|
|
||||||
console.log(`git createRef failed, trying branches endpoint: ${createRefError.message}`);
|
|
||||||
|
|
||||||
// Use Gitea's branch creation endpoint
|
// If API creation succeeded, checkout the new branch
|
||||||
const response = await octokits.rest.request('POST /repos/{owner}/{repo}/branches', {
|
await $`git fetch origin --depth=1 ${newBranch}`;
|
||||||
owner,
|
await $`git checkout ${newBranch}`;
|
||||||
repo,
|
} catch (createRefError: any) {
|
||||||
new_branch_name: newBranch,
|
// If git/refs creation fails (like in Gitea), fall back to Git CLI
|
||||||
old_branch_name: sourceBranch,
|
console.log(`git createRef failed, using Git CLI fallback: ${createRefError.message}`);
|
||||||
});
|
|
||||||
console.log(`Created branch via branches endpoint: ${response.status}`);
|
// Use Git CLI to create and checkout the branch locally, then push it
|
||||||
|
await $`git checkout -b ${newBranch}`;
|
||||||
|
await $`git push origin ${newBranch}`;
|
||||||
|
console.log(`Created branch via Git CLI: ${newBranch}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkout the new branch (shallow fetch for performance)
|
|
||||||
await $`git fetch origin --depth=1 ${newBranch}`;
|
|
||||||
await $`git checkout ${newBranch}`;
|
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`Successfully created and checked out new branch: ${newBranch}`,
|
`Successfully created and checked out new branch: ${newBranch}`,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user