Repository navigation
Prevent branch name reuse across PR history - #250
Merged
Merged
Conversation
- Reject worktree creation if the computed branch name already exists locally, on a remote, or in PR history. This prevents a fresh worktree from inheriting a stale/merged PR immediately after creation. - Wrap getPRForBranch in try/catch so GitHub API failures don't block worktree creation - Fix remote branch matching to compare full branch name after refs/remotes/<remote>/ prefix, preventing false positives - Wrap updateWorktreeMeta in try/catch so meta-update failures don't leave the dialog in an error state for an already-created worktree
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
- Reject worktree creation if the computed branch name already exists locally, on a remote, or in PR history. This prevents a fresh worktree from inheriting a stale/merged PR immediately after creation. - Wrap getPRForBranch in try/catch so GitHub API failures don't block worktree creation - Fix remote branch matching to compare full branch name after refs/remotes/<remote>/ prefix, preventing false positives - Wrap updateWorktreeMeta in try/catch so meta-update failures don't leave the dialog in an error state for an already-created worktree
2 of 3 tasks
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.
Problem
When creating a new worktree with a computed branch name, if that branch name had been used before (e.g., a PR was created and merged), the UI would immediately inherit the stale PR status. This happened because the UI resolves PR state by branch name alone, without checking if the PR is actually active or has been closed/merged.
Additionally, the old code would silently suffix the branch name if it already existed locally, which violated the principle of "no silent renames" and could cause confusing behavior.
Solution
Branch conflict detection: Check if the branch name already exists locally, remotely, or in PR history before allowing creation. If any conflict is found, reject the worktree creation with a clear error message.
git show-ref refs/heads/<name>git for-each-ref refs/remotes/with proper path parsinggetPRForBranch()with graceful fallback on API failuresError handling improvements:
getPRForBranchin try/catch so GitHub API outages don't block worktree creation/separatorsupdateWorktreeMetain try/catch so meta-update failures don't trap the dialog in an error state for an already-created worktreeUI feedback: Display inline error messages when branch creation fails, allowing users to pick a different name.
Testing
getBranchConflictKind()covering local, remote, and no-conflict scenarios