MCPcopy Index your code
hub / github.com/garrytan/gstack / createTestRepo

Function createTestRepo

test/worktree.test.ts:17–38  ·  view source on GitHub ↗

Create a minimal git repo in a tmpdir for testing.

()

Source from the content-addressed store, hash-verified

15
16/** Create a minimal git repo in a tmpdir for testing. */
17function createTestRepo(): string {
18 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'worktree-test-'));
19 spawnSync('git', ['init'], { cwd: dir, stdio: 'pipe' });
20 spawnSync('git', ['config', 'user.email', 'test@test.com'], { cwd: dir, stdio: 'pipe' });
21 spawnSync('git', ['config', 'user.name', 'Test'], { cwd: dir, stdio: 'pipe' });
22
23 // Create initial commit so HEAD exists
24 fs.writeFileSync(path.join(dir, 'README.md'), '# Test repo\n');
25 // Add .gitignore matching real repo (so copied build artifacts don't appear as changes)
26 fs.writeFileSync(path.join(dir, '.gitignore'), '.agents/\nbrowse/dist/\n.gstack-worktrees/\n');
27 // Create a .agents directory (simulating gitignored build artifacts)
28 fs.mkdirSync(path.join(dir, '.agents', 'skills'), { recursive: true });
29 fs.writeFileSync(path.join(dir, '.agents', 'skills', 'test-skill.md'), '# Test skill\n');
30 // Create browse/dist (simulating build artifacts)
31 fs.mkdirSync(path.join(dir, 'browse', 'dist'), { recursive: true });
32 fs.writeFileSync(path.join(dir, 'browse', 'dist', 'browse'), '#!/bin/sh\necho browse\n');
33
34 spawnSync('git', ['add', 'README.md', '.gitignore'], { cwd: dir, stdio: 'pipe' });
35 spawnSync('git', ['commit', '-m', 'Initial commit'], { cwd: dir, stdio: 'pipe' });
36
37 return dir;
38}
39
40/** Clean up a test repo. */
41function cleanupRepo(dir: string): void {

Callers 1

worktree.test.tsFile · 0.85

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected