fix(scripts): honor feature.json branch bypass in check-prerequisites (bash + PowerShell)#2888
Open
PascalThuet wants to merge 2 commits into
Open
fix(scripts): honor feature.json branch bypass in check-prerequisites (bash + PowerShell)#2888PascalThuet wants to merge 2 commits into
PascalThuet wants to merge 2 commits into
Conversation
setup-plan and setup-tasks skip the feature-branch check when .specify/feature.json pins an existing feature directory, but check-prerequisites did not — so on the same branch with the same feature.json, /speckit.plan and /speckit.tasks succeeded while /speckit.checklist, /speckit.analyze, /speckit.implement and /speckit.taskstoissues failed with "Not on a feature branch". Wrap the branch check in check-prerequisites.sh and check-prerequisites.ps1 with the same feature_json_matches_feature_dir / Test-FeatureJsonMatchesFeatureDir guard the setup scripts use. The bypass only skips the branch-name check, not the plan.md / tasks.md existence checks. Add tests covering both languages. Fixes github#2887 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Self-review fixes: - The PS "fails without feature.json" test only asserted a non-zero exit, which the later "feature dir not found" check also produces — it would stay green even if the branch guard were reverted. Assert the "Not on a feature branch" message so the branch check is the proven failure cause (matches the bash test and the sibling setup-plan/setup-tasks tests). - Add safety tests: feature.json pinning a non-existent dir, and malformed feature.json — both must fail safe (enforce the branch check), pinning the property that the bypass only triggers on a real match. - Align the PS branch call to the space-bound `-HasGit` used by the sibling scripts this change mirrors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2887
Problem
setup-planandsetup-tasksskip the "must be on a feature branch" check when.specify/feature.jsonpins an existing feature directory.check-prerequisitesdid not apply this bypass in its validating modes. So on the same branch with the samefeature.json,/speckit.planand/speckit.taskssucceed while/speckit.checklist,/speckit.analyze,/speckit.implementand/speckit.taskstoissuesfail with "Not on a feature branch".Affected both script sets —
check-prerequisites.shandcheck-prerequisites.ps1(the bypass lived only insetup-plan/setup-tasks).Change
Wrap the branch check in both
check-prerequisites.shandcheck-prerequisites.ps1with the samefeature_json_matches_feature_dir/Test-FeatureJsonMatchesFeatureDirguard the setup scripts already use.REPO_ROOT/FEATURE_DIRare already in scope. The bypass only skips the branch-name check — theplan.md/tasks.mdexistence checks still run.Testing
New
tests/test_check_prerequisites_feature_json.py(mirrorstest_setup_plan_feature_json.py):--json, and--require-tasks --include-tasks); fails without feature.json;--paths-onlyalways succeeds.uv run python -m pytest tests/test_check_prerequisites_feature_json.py tests/test_check_prerequisites_paths_only.py tests/test_setup_plan_feature_json.py tests/test_setup_tasks.py→ all green (PowerShell cases skipped locally).🤖 Generated with Claude Code