diff --git a/tests/helpers.cjs b/tests/helpers.cjs index 76a809b95..68b773af7 100644 --- a/tests/helpers.cjs +++ b/tests/helpers.cjs @@ -33,8 +33,28 @@ function createTempProject() { return tmpDir; } +// Create temp directory with initialized git repo and at least one commit +function createTempGitProject() { + const tmpDir = fs.mkdtempSync(path.join(require('os').tmpdir(), 'gsd-test-')); + fs.mkdirSync(path.join(tmpDir, '.planning', 'phases'), { recursive: true }); + + execSync('git init', { cwd: tmpDir, stdio: 'pipe' }); + execSync('git config user.email "test@test.com"', { cwd: tmpDir, stdio: 'pipe' }); + execSync('git config user.name "Test"', { cwd: tmpDir, stdio: 'pipe' }); + + fs.writeFileSync( + path.join(tmpDir, '.planning', 'PROJECT.md'), + '# Project\n\nTest project.\n' + ); + + execSync('git add -A', { cwd: tmpDir, stdio: 'pipe' }); + execSync('git commit -m "initial commit"', { cwd: tmpDir, stdio: 'pipe' }); + + return tmpDir; +} + function cleanup(tmpDir) { fs.rmSync(tmpDir, { recursive: true, force: true }); } -module.exports = { runGsdTools, createTempProject, cleanup, TOOLS_PATH }; +module.exports = { runGsdTools, createTempProject, createTempGitProject, cleanup, TOOLS_PATH };