Skip to content

Commit d26415d

Browse files
committed
fix: authenticate git checkout in GitHub App webhook clone
Partial clones dropped auth on checkout, causing promisor fetch failures on Railway when reviewing PRs.
1 parent f77e00e commit d26415d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

github-app-server/src/server.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,22 @@ async function postIssueComment(repository: GitHubRepo, issueNumber: number, bod
333333
);
334334
}
335335

336-
async function cloneRepository(repository: GitHubRepo, headSha: string, repoDir: string, token: string): Promise<void> {
336+
function gitAuthConfig(token: string): string[] {
337337
const authHeader = Buffer.from(`x-access-token:${token}`).toString("base64");
338+
return ["-c", `http.https://github.com/.extraheader=AUTHORIZATION: basic ${authHeader}`];
339+
}
340+
341+
async function cloneRepository(repository: GitHubRepo, headSha: string, repoDir: string, token: string): Promise<void> {
342+
const auth = gitAuthConfig(token);
343+
// Avoid --filter=blob:none: checkout fetches blobs via promisor remote without inherited auth in Docker.
338344
await runProcess("git", [
339-
"-c",
340-
`http.https://github.com/.extraheader=AUTHORIZATION: basic ${authHeader}`,
345+
...auth,
341346
"clone",
342347
"--no-checkout",
343-
"--filter=blob:none",
344348
repository.clone_url,
345349
repoDir,
346350
]);
347-
await runProcess("git", ["checkout", headSha], { cwd: repoDir });
351+
await runProcess("git", [...auth, "checkout", headSha], { cwd: repoDir });
348352
}
349353

350354
async function runGauntletCI(diffPath: string, repoDir: string): Promise<{ exitCode: number; stdout: string; stderr: string }> {

0 commit comments

Comments
 (0)