(dir: Fixture)
| 105 | export const tempdir = f.temp; |
| 106 | |
| 107 | export async function gitdir(dir: Fixture) { |
| 108 | const cwd = await testdir(dir); |
| 109 | await spawn("git", ["init"], { cwd }); |
| 110 | // 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) |
| 111 | { |
| 112 | const { stdout } = await spawn( |
| 113 | "git", |
| 114 | ["rev-parse", "--abbrev-ref", "HEAD"], |
| 115 | { cwd } |
| 116 | ); |
| 117 | if (stdout.toString("utf8").trim() !== "main") { |
| 118 | await spawn("git", ["checkout", "-b", "main"], { cwd }); |
| 119 | } |
| 120 | } |
| 121 | await spawn("git", ["config", "user.email", "x@y.z"], { cwd }); |
| 122 | await spawn("git", ["config", "user.name", "xyz"], { cwd }); |
| 123 | await spawn("git", ["config", "commit.gpgSign", "false"], { cwd }); |
| 124 | await spawn("git", ["config", "tag.gpgSign", "false"], { cwd }); |
| 125 | await spawn("git", ["config", "tag.forceSignAnnotated", "false"], { |
| 126 | cwd, |
| 127 | }); |
| 128 | |
| 129 | await spawn("git", ["add", "."], { cwd }); |
| 130 | await spawn("git", ["commit", "-m", "initial commit", "--allow-empty"], { |
| 131 | cwd, |
| 132 | }); |
| 133 | |
| 134 | return cwd; |
| 135 | } |
no test coverage detected