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:
@@ -113,18 +113,33 @@ export async function setupBranch(
|
||||
repo,
|
||||
branch: sourceBranch,
|
||||
});
|
||||
currentSHA = branchResponse.data.commit.sha;
|
||||
// Gitea uses commit.id instead of commit.sha
|
||||
currentSHA = branchResponse.data.commit.sha || branchResponse.data.commit.id;
|
||||
}
|
||||
|
||||
console.log(`Current SHA: ${currentSHA}`);
|
||||
|
||||
// Create branch using GitHub API
|
||||
// Create branch - try GitHub API first, fallback to Gitea API
|
||||
try {
|
||||
await octokits.rest.git.createRef({
|
||||
owner,
|
||||
repo,
|
||||
ref: `refs/heads/${newBranch}`,
|
||||
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
|
||||
const response = await octokits.request('POST /repos/{owner}/{repo}/branches', {
|
||||
owner,
|
||||
repo,
|
||||
new_branch_name: newBranch,
|
||||
old_branch_name: sourceBranch,
|
||||
});
|
||||
console.log(`Created branch via branches endpoint: ${response.status}`);
|
||||
}
|
||||
|
||||
// Checkout the new branch (shallow fetch for performance)
|
||||
await $`git fetch origin --depth=1 ${newBranch}`;
|
||||
|
||||
Reference in New Issue
Block a user