Skip to content

Commit f9c7343

Browse files
committed
test: fix tests creating a branch in the precise-commits repository
1 parent 50f4935 commit f9c7343

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

test/git-utils.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ describe("git-utils", () => {
3737
});
3838

3939
it(`should resolve the correct working tree path in a working tree created by git worktree`, async () => {
40-
await tempy.directory.task(async worktreePath => {
41-
runCommandSync("git", ["worktree", "add", "-B", "worktree", worktreePath]);
42-
const subdirPath = `${worktreePath}${sep}subdir`;
43-
await mkdirp(subdirPath);
44-
expect(resolveGitWorkingTreePath(subdirPath)).toEqual(worktreePath);
45-
runCommandSync("git", ["worktree", "remove", worktreePath]);
40+
await tempy.directory.task(async repositoryPath => {
41+
runCommandSync("git", ["init"], repositoryPath);
42+
runCommandSync(
43+
"git",
44+
["commit", "--allow-empty", "-m", "initial commit"],
45+
repositoryPath
46+
);
47+
await tempy.directory.task(async worktreePath => {
48+
runCommandSync(
49+
"git",
50+
["worktree", "add", "-B", "worktree", worktreePath],
51+
repositoryPath
52+
);
53+
const subdirPath = `${worktreePath}${sep}subdir`;
54+
await mkdirp(subdirPath);
55+
expect(resolveGitWorkingTreePath(subdirPath)).toEqual(worktreePath);
56+
runCommandSync("git", ["worktree", "remove", worktreePath], repositoryPath);
57+
});
4658
});
4759
});
4860
});

0 commit comments

Comments
 (0)