MCPcopy Create free account
hub / github.com/garrytan/gstack / createRepo

Function createRepo

test/diff-scope.test.ts:17–45  ·  view source on GitHub ↗
(files: string[])

Source from the content-addressed store, hash-verified

15const dirs: string[] = [];
16
17function createRepo(files: string[]): string {
18 const dir = mkdtempSync(join(tmpdir(), 'diff-scope-test-'));
19 dirs.push(dir);
20
21 const run = (cmd: string, args: string[]) =>
22 spawnSync(cmd, args, { cwd: dir, stdio: 'pipe', timeout: 5000 });
23
24 run('git', ['init', '-b', 'main']);
25 run('git', ['config', 'user.email', 'test@test.com']);
26 run('git', ['config', 'user.name', 'Test']);
27
28 // Base commit
29 writeFileSync(join(dir, 'README.md'), '# test\n');
30 run('git', ['add', '.']);
31 run('git', ['commit', '-m', 'initial']);
32
33 // Feature branch with specified files
34 run('git', ['checkout', '-b', 'feature/test']);
35 for (const f of files) {
36 const fullPath = join(dir, f);
37 const dirPath = fullPath.substring(0, fullPath.lastIndexOf('/'));
38 if (dirPath !== dir) mkdirSync(dirPath, { recursive: true });
39 writeFileSync(fullPath, '# test content\n');
40 }
41 run('git', ['add', '.']);
42 run('git', ['commit', '-m', 'add files']);
43
44 return dir;
45}
46
47function runScope(dir: string): Record<string, string> {
48 const result = spawnSync('bash', [SCRIPT, 'main'], {

Callers 1

diff-scope.test.tsFile · 0.85

Calls 2

runFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected