Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4097,6 +4097,37 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("leaves FETCH_HEAD to the user's own pulls in background upstream fetches", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
const remote = yield* makeTmpDir("git-vcs-driver-remote-");
const updater = yield* makeTmpDir("git-vcs-driver-updater-");
const { initialBranch } = yield* initRepoWithCommit(cwd);
yield* git(remote, ["init", "--bare"]);
yield* git(cwd, ["remote", "add", "origin", remote]);
yield* git(cwd, ["push", "-u", "origin", initialBranch]);

yield* git(updater, ["clone", remote, "."]);
yield* git(updater, ["config", "user.email", "test@test.com"]);
yield* git(updater, ["config", "user.name", "Test"]);
yield* writeTextFile(updater, "remote.txt", "remote\n");
yield* git(updater, ["add", "remote.txt"]);
yield* git(updater, ["commit", "-m", "remote commit"]);
yield* git(updater, ["push", "origin", initialBranch]);
const fetchHeadPath = (yield* Path.Path).join(cwd, ".git", "FETCH_HEAD");
assert.equal(NodeFS.existsSync(fetchHeadPath), false);

const status = yield* (yield* GitVcsDriver.GitVcsDriver).statusDetailsRemote(cwd);

assert.equal(status.behindCount, 1);
assert.equal(
NodeFS.existsSync(fetchHeadPath),
false,
"background status fetch wrote .git/FETCH_HEAD, which an overlapping `git pull` merges from",
);
}),
);

it.effect("uses origin HEAD for default-branch detection with a non-origin upstream", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
"--quiet",
"--no-tags",
"--no-auto-gc",
// FETCH_HEAD is written without a lock; overlapping a user's `git pull` makes that pull fail.
"--no-write-fetch-head",
"--",
remoteName,
];
Expand Down
Loading