Skip to content
Merged
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
8 changes: 7 additions & 1 deletion tests/tooling/CIGitLogic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ async function initGitServer() {
fs.mkdirSync(GIT_REMOTE, {recursive: true});
process.chdir(GIT_REMOTE);
await $`git init -b main`;
// Detached maintenance must not keep changing files after an awaited Git command finishes.
await $`git config --local maintenance.auto false`;
await setupGitAsHuman();
await $`npm init -y`;
await $`npm version --no-git-tag-version 1.0.0-0`;
Expand All @@ -219,13 +221,17 @@ async function initGitServer() {
}

async function checkoutRepo() {
// The previous checkout may still be the cwd when it is replaced.
process.chdir(SANDBOX_DIR);
if (fs.existsSync(DUMMY_DIR)) {
Log.warn(`Found existing directory at ${DUMMY_DIR}, deleting it to simulate a fresh checkout...`);
fs.rmSync(DUMMY_DIR, {recursive: true});
fs.rmSync(DUMMY_DIR, {recursive: true, force: true});
}
fs.mkdirSync(DUMMY_DIR);
process.chdir(DUMMY_DIR);
await $`git init`;
// This setting is local to each fresh checkout, leaving the developer's Git configuration untouched.
await $`git config --local maintenance.auto false`;
await $`git remote add origin ${GIT_REMOTE}`;
await $`git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/main:refs/remotes/origin/main`;
await $`git checkout --progress --force -B main refs/remotes/origin/main`;
Expand Down
Loading