Skip to content

Commit 1de439f

Browse files
committed
Only mark directories as safe if not already marked
1 parent 4ecc785 commit 1de439f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/runner.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ before(function() {
8787
return fse.writeFile(local("home", ".gitconfig"),
8888
"[user]\n name = John Doe\n email = johndoe@example.com");
8989
})
90-
.then( async function() {
91-
//mark all test repos as safe
92-
for(let repo of testRepos) {
93-
await exec(`git config --global --add safe.directory ${local(repo)}`);
90+
.then(async function() {
91+
// mark test repos as safe if not already marked
92+
const currentSafeDirectories = new Set((await exec("git config --global --get-all safe.directory")).trim().split("\n"));
93+
const directoriesToMarkAsSafe = testRepos.filter(testRepo => !currentSafeDirectories.has(testRepo));
94+
for (const directory of directoriesToMarkAsSafe) {
95+
await exec(`git config --global --add safe.directory ${local(directory)}`);
9496
}
9597
})
9698
});

0 commit comments

Comments
 (0)