fix(up): track remote-only branches; refuse slug collisions with a different branch#22
Merged
Merged
Conversation
…fferent branch Two branch-resolution gaps: WorktreeManager::create only checked local branches, so a branch that exists on origin but not locally (the resume-a-PR-branch workflow) was forked fresh from HEAD under the same name — silently the wrong base. create() now checks refs/remotes/origin/<branch> (no network) and uses 'worktree add --track -b <branch> origin/<branch>' for remote-only branches. The resume path matched sessions by slug only. Slugs are sanitized branch names (feat/foo -> feat-foo), so 'ecluse up feat/foo' silently resumed a session created from branch 'feat-foo' — wrong branch, no signal. An explicit argument now resumes only when it matches the session's slug or exact branch; a colliding branch errors with the session's actual branch and a next step. Test fixtures additionally disable commit signing so they work in environments with commit.gpgsign=true. Fixes #6 https://claude.ai/code/session_017UcuvzMKHVfyBCcq8ipAko
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 #6
Remote-only branches are now tracked, not forked (
worktree.rs)WorktreeManager::createdecided between "reuse branch" and "create new branch from HEAD" usinggit branch --list— local branches only. A branch existing only onorigin(the typical "resume this PR branch" agent workflow) took the-bpath: a brand-new branch forked from the current HEAD under the same name, silently on the wrong base.create()now has three cases:worktree add <path> <branch>(unchanged)refs/remotes/origin/<branch>exists (checked viarev-parse --verify, no network) →worktree add --track -b <branch> <path> origin/<branch>Slug collisions no longer silently resume the wrong branch (
main.rs)Slugs are sanitized branch names (
feat/foo→feat-foo), so two different branches can collide on one slug. The resume path matched by slug only:ecluse up feat/fooagainst a session created from branchfeat-foosilently resumed the other branch.New rule, preserving normal resume ergonomics:
up <slug>(exact slug match) → resumes, as beforeup <branch>where the branch matches the session's branch → resumes, as beforeecluse down <slug>as the next stepTests
create_tracks_remote_only_branch— upstream + clone fixture; asserts the worktree's branch tracksorigin/feat-remoteand starts at the remote tip, not at HEAD (fails on the old fork-from-HEAD behavior)up_with_colliding_branch_name_errors—up feat-foo, thenup feat/fooerrors, thenup feat-foostill resumes-c commit.gpgsign=falseso the suite runs in environments with commit signing configured globallycargo fmt --check,cargo clippy -- -D warnings,cargo test(370 + 19) green.https://claude.ai/code/session_017UcuvzMKHVfyBCcq8ipAko
Generated by Claude Code