MCPcopy Index your code
hub / github.com/changesets/changesets / gitdir

Function gitdir

scripts/test-utils/src/index.ts:107–135  ·  view source on GitHub ↗
(dir: Fixture)

Source from the content-addressed store, hash-verified

105export const tempdir = f.temp;
106
107export 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}

Callers 4

index.test.tsFile · 0.90
add.tsFile · 0.90
status.tsFile · 0.90
index.test.tsFile · 0.90

Calls 1

testdirFunction · 0.85

Tested by

no test coverage detected