Skip to content

fix(#1491): new-feature.sh exits 1 when the issue's local branch exists without a worktree, while sequant run reuses the branch - #1517

Merged
admarble merged 3 commits into
mainfrom
feature/1491-fix-worktree-new-feature-sh-exits-1-when-the-issue
Oct 19, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/1491-fix-worktree-new-feature-sh-exits-1-when-the-issue

Conversation

@admarble

@admarble admarble commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When the issue's local branch exists and no worktree has it checked out, new-feature.sh now creates the worktree on that branch as is and exits 0, instead of exiting 1 with advice. This matches ensureWorktree's existing-branch rule: no fetch, no reset, and never origin/<branch>. A recorded sequantBase on the existing branch is kept. The worktree lookup now matches the branch ref exactly, so feature/7-x is not taken for feature/7-xy. A branch already checked out in a worktree and a new branch behave as before. scripts/new-feature.sh is a symlink to templates/scripts/new-feature.sh, so there is one copy.

Fixes #1491

Verification

The tests drive the real script with gh stubbed.

  • AC-1: npx vitest run __tests__/new-feature-existing-branch.integration.test.ts -t "local branch without a worktree" → 1 passed, 0 failed.
  • AC-2: -t "existing-branch parity" → 3 passed, 0 failed.
  • AC-3: -t "worktree already checked out" → 2 passed; npx vitest run __tests__/new-feature-worktree-root.integration.test.ts __tests__/new-feature-checkout-guard.integration.test.ts → 7 passed, 0 failed.

Mutation-verified: AC-1 — restored the exit 1 advice branch for a local branch without a worktree; tests/new-feature-existing-branch.integration.test.ts > new-feature.sh existing local branch (#1491) > local branch without a worktree: creates the worktree on it and exits 0 failed, along with the 3 parity cases and the longer-name case, which take the same path (5 failed); restored.

Mutation-verified: AC-2 — made the existing-branch path start from origin/ when it exists; tests/new-feature-existing-branch.integration.test.ts > new-feature.sh existing local branch (#1491) > existing-branch parity > local branch behind origin/ -> local tip, not origin's failed (1 failed, 6 passed); restored.

🤖 Generated with Claude Code

…rktree has it

Check the branch out as is, like ensureWorktree, instead of exiting 1. Match the existing worktree exactly.

Entire-Checkpoint: 8799a05c2fe6
@admarble
admarble merged commit f88aaf7 into main Oct 19, 2026
8 checks passed
@admarble
admarble deleted the feature/1491-fix-worktree-new-feature-sh-exits-1-when-the-issue branch October 19, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(worktree): new-feature.sh exits 1 when the issue's local branch exists without a worktree, while sequant run reuses the branch

1 participant