Skip to content

feat: use prefixed branch name for conflicting fork PR branches - #779

Merged
max-sixty merged 7 commits into
mainfrom
conflicting-branches
Jan 21, 2026
Merged

max-sixty merged 7 commits into
mainfrom
conflicting-branches

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

  • When a fork PR's branch name conflicts with an existing local branch, use a prefixed name (contributor/main) instead of failing
  • Show warning about push limitations with prefixed branches
  • Link to Improve support for GitHub fork PRs #714 for user feedback

Closes #714

Test plan

  • Unit test for prefixed_local_branch_name()
  • Integration tests for conflict scenarios updated
  • All tests pass

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 7 commits January 21, 2026 11:39
When a fork PR's branch name conflicts with an existing local branch
(e.g., contributor opens PR from their `main` branch), create a prefixed
branch name like `contributor/main` instead of failing.

This allows users to checkout and review fork PRs even when the branch
name is taken locally. Push to fork is not supported with prefixed
branches since git push requires matching local/remote names.

Closes #714

Co-Authored-By: Claude <[email protected]>
Add integration tests for:
- Prefixed branch already exists and tracks same PR (reuse)
- Prefixed branch exists but tracks different PR (error)

Co-Authored-By: Claude <[email protected]>
The test was creating a worktree at `test-repo.contributor-feature-fix`
but the test repo's directory is named `repo`, not `test-repo`. This
caused the snapshot path normalization to fail on CI.

Changed the path to `repo.contributor-feature-fix` to match the test
repo's naming convention, ensuring consistent path normalization.

Co-Authored-By: Claude <[email protected]>
Changed the error detection in `fetch_pr_info()` from string matching
to using `std::io::ErrorKind::NotFound`, which is the cross-platform
approach already used in `fetch_mr_info()`.

String matching ("No such file", "not found", "cannot find") was
failing on Windows where the error message format differs.

Co-Authored-By: Claude <[email protected]>
On Windows, creating symlinks requires Developer Mode or admin
privileges. The tests that simulate "gh/glab not installed" by
creating a minimal PATH with only git now gracefully skip if symlink
creation fails.

Also simplified the error detection in pr_ref.rs to use ErrorKind
instead of string matching, matching the approach in mr_ref.rs.

Co-Authored-By: Claude <[email protected]>
On Windows, git requires its entire installation directory to function
correctly - just symlinking git.exe isn't enough. We can't easily
create a minimal PATH with just git while excluding gh/glab without
breaking git itself.

Skip these tests on Windows using cfg(windows). The tests verify that
the error message is correct when gh/glab isn't installed, but this
specific behavior is adequately tested on Linux/macOS.

Co-Authored-By: Claude <[email protected]>
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.

Improve support for GitHub fork PRs

1 participant