Skip to content

Commit 0267cdf

Browse files
authored
speed up gitdir function by ~20% (#1960)
1 parent 25c6d59 commit 0267cdf

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

scripts/test-utils/src/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export async function testdir(dir?: Fixture) {
105105

106106
export async function gitdir(dir: Fixture) {
107107
const cwd = await testdir(dir);
108+
108109
await exec("git", ["init"], { nodeOptions: { cwd } });
109110
// so that this works regardless of what the default branch of git init is and for git versions that don't support --initial-branch(like our CI)
110111
{
@@ -117,19 +118,18 @@ export async function gitdir(dir: Fixture) {
117118
await exec("git", ["checkout", "-b", "main"], { nodeOptions: { cwd } });
118119
}
119120
}
120-
await exec("git", ["config", "user.email", "x@y.z"], {
121-
nodeOptions: { cwd },
122-
});
123-
await exec("git", ["config", "user.name", "xyz"], { nodeOptions: { cwd } });
124-
await exec("git", ["config", "commit.gpgSign", "false"], {
125-
nodeOptions: { cwd },
126-
});
127-
await exec("git", ["config", "tag.gpgSign", "false"], {
128-
nodeOptions: { cwd },
129-
});
130-
await exec("git", ["config", "tag.forceSignAnnotated", "false"], {
131-
nodeOptions: { cwd },
132-
});
121+
122+
const gitConfig = `
123+
[user]
124+
email = x@y.z
125+
name = xyz
126+
[commit]
127+
gpgSign = false
128+
[tag]
129+
gpgSign = false
130+
forceSignAnnotated = false
131+
`.trim();
132+
await fsp.appendFile(path.join(cwd, ".git/config"), gitConfig, "utf8");
133133

134134
await exec("git", ["add", "."], { nodeOptions: { cwd } });
135135
await exec("git", ["commit", "-m", "initial commit", "--allow-empty"], {

0 commit comments

Comments
 (0)