From 339966e27dea01441e508d0af74957599118fb0a Mon Sep 17 00:00:00 2001 From: Ethan Hurst Date: Wed, 25 Feb 2026 13:37:13 +1000 Subject: [PATCH] feat(03-01): add createTempGitProject helper to tests/helpers.cjs - Creates temp dir with .planning/phases structure - Initializes git repo with user config - Writes initial PROJECT.md and commits it - Exports createTempGitProject alongside existing helpers --- tests/helpers.cjs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 };