fix: use repos.getBranch() on Forgejo for branch SHA lookup

Forgejo uses /git/refs (plural) not /git/ref (singular), causing
git.getRef() to 404. Use repos.getBranch() on Forgejo instead,
which returns the same SHA data via a compatible endpoint.

Also adds the tag mode workflow (.forgejo/workflows/claude.yml)
for @claude mentions on issues, PR reviews, and label triggers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-25 20:02:24 +02:00
1 parent c2ea0a6dba
commit 87b7fec838
1 file changed
+20 -8
+20 -8
View File
@@ -13,6 +13,7 @@ import type { GitHubPullRequest } from "../types";
import type { Octokits } from "../api/client";
import type { FetchDataResult } from "../data/fetcher";
import { generateBranchName } from "../../utils/branch-template";
import { detectPlatform } from "../../platform/detector";
/**
* Extracts the first label from GitHub data, or returns undefined if no labels exist
@@ -204,14 +205,25 @@ export async function setupBranch(
let sourceSHA: string | undefined;
try {
// Get the SHA of the source branch to verify it exists
const sourceBranchRef = await octokits.rest.git.getRef({
owner,
repo,
ref: `heads/${sourceBranch}`,
});
sourceSHA = sourceBranchRef.data.object.sha;
// Get the SHA of the source branch to verify it exists.
// Forgejo uses /git/refs (plural) not /git/ref (singular), so
// git.getRef() 404s. Use repos.getBranch() on Forgejo instead.
const platform = detectPlatform();
if (platform === "forgejo") {
const branchResponse = await octokits.rest.repos.getBranch({
owner,
repo,
branch: sourceBranch,
});
sourceSHA = branchResponse.data.commit.sha;
} else {
const sourceBranchRef = await octokits.rest.git.getRef({
owner,
repo,
ref: `heads/${sourceBranch}`,
});
sourceSHA = sourceBranchRef.data.object.sha;
}
console.log(`Source branch SHA: ${sourceSHA}`);
// Extract first label from GitHub data