summaryrefslogtreecommitdiff
path: root/tests/claude-code/test-executing-plans-scripts.sh
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2026-10-22 23:25:30 +0000
committerJesse Vincent <jesse@fsck.com>2026-10-23 00:21:52 +0000
commitde67241e0a8f241b5607f99c3891d5e517e2cf47 (patch)
treec77941185b9c21d1c3dc8ef219429c7523d6555c /tests/claude-code/test-executing-plans-scripts.sh
parent614d80c29a4ad0c0fffb8c49ce5fc5b8afa0bf42 (diff)
fix(sdd): one no-repo message that puts "run from your working tree" first
sdd-repo's no-repository message told every caller to run 'git init'. That is the right fix for a new project, but the other way to reach it is standing in the wrong directory, such as the plugin's own skill directory after reading "from this skill's directory" literally. There, 'git init' would turn the plugin cache into a repository and hide the real mistake. task-start and task-done were worse. They still read HEAD and BASE in the bare cwd while the brief and ledger went through sdd-repo. From a non-repo cwd with the plan in a repo that has commits, task-start wrote the brief into the plan's repo, then printed git's fatal plus "HEAD has no commit yet ... make an initial commit first" and exited 2. task-done printed git's fatal. review-package in a repo with no commit said "bad BASE: HEAD~1". Every helper that can hit this (sdd-workspace, task-brief, review-package, task-start, task-done) now stops with the same message from sdd-repo, naming the current directory and offering init-and-commit only as the new-project case: SDD scripts must run from inside the git working tree you're executing in, with at least one commit (current directory: <PWD>). If this is a new project, run 'git init' and make a first commit, then rerun. sdd-repo gains --with-commit, which also refuses a repository whose HEAD has no commit. review-package, task-start and task-done pass it because they need HEAD as a BASE or a review range; sdd-workspace and task-brief do not, so a brief can still be written right after git init. task-start and task-done now read HEAD and BASE with git -C in the repository sdd-repo names. Resolution is otherwise unchanged: the cwd's repo, else the plan's, else exit 2. sdd-repo is now executable like its siblings. Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba
Diffstat (limited to 'tests/claude-code/test-executing-plans-scripts.sh')
-rwxr-xr-xtests/claude-code/test-executing-plans-scripts.sh57
1 files changed, 52 insertions, 5 deletions
diff --git a/tests/claude-code/test-executing-plans-scripts.sh b/tests/claude-code/test-executing-plans-scripts.sh
index 08ba02d..d09d97c 100755
--- a/tests/claude-code/test-executing-plans-scripts.sh
+++ b/tests/claude-code/test-executing-plans-scripts.sh
@@ -154,15 +154,62 @@ PLAN
echo " ledger:"; sed 's/^/ /' "$ledger" 2>/dev/null || echo " (missing)"
fi
- # --- task-start: a repo with no commit yet has no BASE to record (#2242) ---
+ # --- no usable repository: every helper stops with one message (#2242, #2429) ---
+ # The same message for a new project and for a caller standing in the
+ # wrong directory (such as the plugin's skill directory, where git init
+ # is the wrong fix), so "init and commit" is only the new-project case.
git init -q -b main "$TEST_ROOT/unborn"
cp "$repo/plan.md" "$TEST_ROOT/unborn/plan.md"
+ mkdir -p "$TEST_ROOT/no-repo"
+ cp "$repo/plan.md" "$TEST_ROOT/no-repo/plan.md"
+ local where msg
+ for where in unborn no-repo; do
+ msg="SDD scripts must run from inside the git working tree you're executing in, with at least one commit (current directory: $TEST_ROOT/$where). If this is a new project, run 'git init' and make a first commit, then rerun."
+ rc=0
+ out="$(cd "$TEST_ROOT/$where" && "$EP_SCRIPTS/task-start" plan.md 1 2>&1)" || rc=$?
+ if [[ "$rc" -eq 2 && "$out" == "$msg" ]]; then
+ pass "task-start in a $where directory exits 2 with the shared message"
+ else
+ fail "task-start in a $where directory exits 2 with the shared message"
+ echo " exit: $rc"
+ echo " got: $out"
+ fi
+ rc=0
+ out="$(cd "$TEST_ROOT/$where" && "$EP_SCRIPTS/task-done" plan.md 1 HEAD -- true 2>&1)" || rc=$?
+ if [[ "$rc" -eq 2 && "$out" == "$msg" ]]; then
+ pass "task-done in a $where directory exits 2 with the shared message"
+ else
+ fail "task-done in a $where directory exits 2 with the shared message"
+ echo " exit: $rc"
+ echo " got: $out"
+ fi
+ done
+ if [[ ! -e "$TEST_ROOT/unborn/.superpowers" && ! -e "$TEST_ROOT/no-repo/.superpowers" ]]; then
+ pass "nothing is written without a usable repository"
+ else
+ fail "nothing is written without a usable repository"
+ fi
+
+ # --- outside any repository, task-start and task-done use the plan's (#2429) ---
+ # The same fallback task-brief takes, so BASE comes from the repository
+ # the brief and ledger were written into, not from the bare cwd.
+ rc=0
+ out="$(cd "$TEST_ROOT/no-repo" && "$EP_SCRIPTS/task-start" "$repo/plan.md" 2 2>&1)" || rc=$?
+ local head_now
+ head_now="$(cd "$repo" && git rev-parse HEAD)"
+ if [[ "$rc" -eq 0 && "$out" == *"brief: $repo/.superpowers/sdd/plan/task-2-brief.md"* && "$out" == *"base: $head_now"* ]]; then
+ pass "task-start outside any repository takes the plan's repository and HEAD"
+ else
+ fail "task-start outside any repository takes the plan's repository and HEAD"
+ echo " exit: $rc"
+ echo " got: $out"
+ fi
rc=0
- out="$(cd "$TEST_ROOT/unborn" && "$EP_SCRIPTS/task-start" plan.md 1 2>&1)" || rc=$?
- if [[ "$rc" -eq 2 && "$out" == *"initial commit"* && "$out" != *"base:"* ]]; then
- pass "task-start before the first commit exits 2 instead of printing a bogus BASE"
+ out="$(cd "$TEST_ROOT/no-repo" && "$EP_SCRIPTS/task-done" "$repo/plan.md" 2 "$head_now" -- true 2>&1)" || rc=$?
+ if [[ "$rc" -eq 0 ]] && grep -q "^Task 2: complete (commits ${head_now:0:7}..${head_now:0:7}," "$repo/.superpowers/sdd/plan/progress.md"; then
+ pass "task-done outside any repository records into the plan's repository"
else
- fail "task-start before the first commit exits 2 instead of printing a bogus BASE"
+ fail "task-done outside any repository records into the plan's repository"
echo " exit: $rc"
echo " got: $out"
fi