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:
1 parent
c2ea0a6dba
commit
87b7fec838
1 file changed
+14
-2
@@ -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.
|
||||||
|
// 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({
|
const sourceBranchRef = await octokits.rest.git.getRef({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
ref: `heads/${sourceBranch}`,
|
ref: `heads/${sourceBranch}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
sourceSHA = sourceBranchRef.data.object.sha;
|
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
|
||||||
|
|||||||
Reference in new issue
Block a user