(files: string[])
| 15 | const dirs: string[] = []; |
| 16 | |
| 17 | function 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 | |
| 47 | function runScope(dir: string): Record<string, string> { |
| 48 | const result = spawnSync('bash', [SCRIPT, 'main'], { |
no test coverage detected