From 87b7fec83800b4388639500a77312a8603c3ac50 Mon Sep 17 00:00:00 2001 From: Vlad Mocanu Date: Wed, 25 Feb 2026 20:02:24 +0200 Subject: [PATCH] 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 --- src/github/operations/branch.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/github/operations/branch.ts b/src/github/operations/branch.ts index 86197da..1492438 100644 --- a/src/github/operations/branch.ts +++ b/src/github/operations/branch.ts @@ -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