Skip to content

Commit 8de7e35

Browse files
fix(server): keep worktree creation working when git config is locked (pingdotgg#11773)
Co-authored-by: Julius Marminge <[email protected]>
1 parent 9a648d4 commit 8de7e35

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,6 +3816,44 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
38163816
}),
38173817
);
38183818

3819+
it.effect("still creates the worktree when the base-ref config is locked", () =>
3820+
Effect.gen(function* () {
3821+
const cwd = yield* makeTmpDir();
3822+
const { initialBranch } = yield* initRepoWithCommit(cwd);
3823+
const pathService = yield* Path.Path;
3824+
const fileSystem = yield* FileSystem.FileSystem;
3825+
const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "locked-config");
3826+
yield* writeTextFile(cwd, ".git/config.lock", "");
3827+
const driver = yield* GitVcsDriver.GitVcsDriver;
3828+
3829+
const created = yield* driver.createWorktree({
3830+
cwd,
3831+
path: worktreePath,
3832+
refName: initialBranch,
3833+
newRefName: "feature/locked-config",
3834+
baseRefName: initialBranch,
3835+
});
3836+
3837+
assert.deepEqual(created.worktree, {
3838+
path: worktreePath,
3839+
refName: "feature/locked-config",
3840+
});
3841+
assert.equal(
3842+
yield* git(worktreePath, ["branch", "--show-current"]),
3843+
"feature/locked-config",
3844+
);
3845+
assert.equal(
3846+
yield* fileSystem.readFileString(pathService.join(worktreePath, "README.md")),
3847+
"# test\n",
3848+
);
3849+
assert.equal(
3850+
yield* driver.readConfigValue(worktreePath, "branch.feature/locked-config.gh-merge-base"),
3851+
null,
3852+
);
3853+
assert.equal(yield* fileSystem.exists(pathService.join(cwd, ".git/config.lock")), true);
3854+
}),
3855+
);
3856+
38193857
it.effect("reports checkout progress during parallel worktree creation", () =>
38203858
Effect.gen(function* () {
38213859
const cwd = yield* makeTmpDir();

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3601,7 +3601,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
36013601
"config",
36023602
`branch.${input.newRefName}.gh-merge-base`,
36033603
baseBranch,
3604-
]);
3604+
]).pipe(
3605+
Effect.catchTags({
3606+
GitCommandError: () =>
3607+
Effect.logWarning(
3608+
"worktree base-ref configuration failed; using base-branch fallback",
3609+
),
3610+
}),
3611+
);
36053612
}
36063613
}
36073614

0 commit comments

Comments
 (0)