CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

Reconcile the GitHub fork back into canonical #5499

MergedXSccantynz wants to mergerecover/github-forkmainopened 16d ago
2 changed files+30−11
Renamedsrc/__tests__/merge-resolver-nonff.test.tssrc/__tests__/git-merge-resolver-nonff.test.ts+6−0View fileUnifiedSplit
1313 * the base ref now points at a merge commit whose parents are the old base
1414 * tip and the head tip. It also asserts a second merge into the same base
1515 * works (the detached-worktree guard against a leaked branch lock).
16 *
17 * FILE NAME MATTERS: `mcp-write.test.ts` calls `mock.module("../lib/merge-
18 * resolver")` with a success no-op, and Bun's mock.module is process-global
19 * — it poisons every later-loading test file that imports the same module.
20 * This file sorts before `mcp-*` so it exercises the real resolver. If you
21 * rename it, keep it lexically before "mcp-write".
1622 */
1723
1824import { describe, it, expect, beforeAll, afterAll } from "bun:test";
Modifiedsrc/lib/pr-merge-gated.ts+24−11View fileUnifiedSplit
290290 // This chain (v2 endpoint + MCP merge) was the one path still missing
291291 // the guard. mergeWithAutoResolve handles the clean non-ff case without
292292 // any AI call, so this is safe even with AI down.
293 const ancestry = Bun.spawnSync(
294 [
295 "git",
296 "merge-base",
297 "--is-ancestor",
298 `refs/heads/${pr.baseBranch}`,
299 `refs/heads/${pr.headBranch}`,
300 ],
301 { cwd: repoDir }
302 );
303 if (ancestry.exitCode !== 0) {
293 // spawnSync THROWS (ENOENT) when the repo dir is missing or git is not
294 // on PATH — never let that escape as a 500 from the merge endpoint.
295 // Treat "could not prove ancestry" as non-fast-forward: the resolver
296 // path below then reports git's own reason honestly.
297 let isAncestor = false;
298 try {
299 const ancestry = Bun.spawnSync(
300 [
301 "git",
302 "merge-base",
303 "--is-ancestor",
304 `refs/heads/${pr.baseBranch}`,
305 `refs/heads/${pr.headBranch}`,
306 ],
307 { cwd: repoDir }
308 );
309 isAncestor = ancestry.exitCode === 0;
310 } catch (err) {
311 console.warn(
312 "[merge] ancestry check could not run:",
313 err instanceof Error ? err.message : err
314 );
315 }
316 if (!isAncestor) {
304317 const mergeResult = await mergeWithAutoResolve(
305318 owner,
306319 repo,
307320
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts