Repository navigation
fix(loop): refuse to cut a feature branch from a base that lacks the feature - #3604
Merged
Merged
Conversation
…feature Closes #3601. When PLAN.md's `branch` did not exist, ensure_feature_branch cut it from the declared `base` with `git checkout -B`. A feature folder committed only on the current branch is absent from that base, so the new branch had no PLAN.md: the next read raised a bare FileNotFoundError and the operator was left on the new branch. ensure_feature_branch now checks, before switching, whether the feature's PLAN.md is committed at HEAD but missing from the base, and raises FeatureBranchError naming the path, the base and the two ways forward. The operator stays on their branch. An untracked folder (the --prepare path) and a base that holds the feature behave as before. The normal `specfuse run` path now prints a FeatureBranchError and exits 1 instead of a traceback, as --prepare already did. Tests: - tests/test_feature_branch_missing_on_base.py:TestFeatureMissingOnBase — refusal before switching (red on unchanged code), plus two controls: base holding the feature, and an untracked folder riding along. Verification: - scripts/smoke-test.sh: 5104 tests OK, smoke test OK Co-Authored-By: Claude Opus 5.5 <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.
Closes #3601.
Root cause
When the branch named in
PLAN.mddid not exist,ensure_feature_branchcut it from the declaredbasewithgit checkout -B. A feature folder committed only on the current branch is absent from that base, so the new branch held noPLAN.md: the next read raised a bareFileNotFoundError, with the operator already moved onto the new branch.Fix
Before switching,
ensure_feature_branchchecks whether the feature'sPLAN.mdis committed atHEADbut missing from the base (git cat-file -e). If so it raisesFeatureBranchErrornaming the path and the base, with two ways forward (create the branch from the current checkout, or merge the feature into the base first). Nothing is switched.Unchanged: a base that holds the feature, and an untracked feature folder (the
--preparepath, whichcheckout -Bcarries along). The guard returns "no refusal" whenever it cannot resolve the path, so it only ever adds a refusal.The normal
specfuse runpath now catchesFeatureBranchError, prints it and exits 1, as--preparealready did, so this and the existing dirty-tree refusal no longer surface as tracebacks.Tests
tests/test_feature_branch_missing_on_base.py: the refusal (red on unchanged code: the branch was created frommainwith no error), plus two controls, a base that holds the feature and an untracked folder riding along.Verification
scripts/smoke-test.sh: 5104 tests OK, smoke test OK.🤖 Generated with Claude Code