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 { Octokits } from "../api/client";
import type { FetchDataResult } from "../data/fetcher"; import type { FetchDataResult } from "../data/fetcher";
import { generateBranchName } from "../../utils/branch-template"; 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 * 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; let sourceSHA: string | undefined;
try { try {
// Get the SHA of the source branch to verify it exists // Get the SHA of the source branch to verify it exists.
const sourceBranchRef = await octokits.rest.git.getRef({ // Forgejo uses /git/refs (plural) not /git/ref (singular), so
owner, // git.getRef() 404s. Use repos.getBranch() on Forgejo instead.
repo, const platform = detectPlatform();
ref: `heads/${sourceBranch}`, if (platform === "forgejo") {
}); const branchResponse = await octokits.rest.repos.getBranch({
owner,
sourceSHA = sourceBranchRef.data.object.sha; 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}`); console.log(`Source branch SHA: ${sourceSHA}`);
// Extract first label from GitHub data // Extract first label from GitHub data