Repository navigation
feat: wt add accepts a pull request from a fork - #10
Merged
Merged
Conversation
Origin has no branch for a pull request from a fork, and wt add refused it. Git cannot name the fork: refs/pull/<n>/head holds only the commit. When origin has no branch at that commit, wt add now asks GitHub with `gh api` for the owner and the branch of the fork. A pull request from origin does not need gh. wt add uses the remote that has the URL of the fork, or it adds a remote with the name of the owner. The URL has the form of the URL of origin, so SSH stays SSH. The local branch has the name of the branch in the fork and tracks <owner>/<branch>. When a local branch has that name and tracks a different branch, for example main, the name is <owner>-<branch>. The same pull request therefore always gives the same branch. A link whose branch wt cannot fetch is now an error. Before, wt add made a new branch from the base branch, and the worktree had none of the commits of the pull request. wt prune does not change. It fetches from origin only, so it keeps the worktree of a pull request from a fork.
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.
wt add <link>refused a pull request from a fork, because origin has no branch at its commit. It now makes the worktree.refs/pull/<n>/headholds only the commit. When origin has no branch at that commit, the command asks GitHub withgh api repos/<owner>/<repo>/pulls/<n>for the owner and the branch of the fork. A pull request from origin does not usegh, as before.<owner>/<branch>. When a local branch has that name and tracks a different branch, for examplemain, the name is<owner>-<branch>. The same pull request always gives the same branch, so a second link goes to the worktree.ghthat is absent or has no login, gives an error.wt prunedoes not change. It fetches from origin only, so it keeps the worktree of a pull request from a fork. The README says to remove it withwt delete.Output for cashubtc/cdk#2736, from crodas/cdk:
Test
The four CI gates (
nix build .#wt .#wt-clippy .#wt-test .#wt-fmt) pass.cargo testruns 48 tests, 6 new. Three of them run the command in a temporary repository with an origin and a fork:masternext to a localmasterthat tracksorigin/mastergivesalice-master, andmasterkeeps its upstream. A second link gives the same branch and adds no remote.The other three read the output of
gh, also for a deleted fork, and choose the URL form from origin. The test for the clash and the test for the failed fetch fail when the behavior that they protect is removed from the code.A manual test in a
.barecopy of cashubtc/cdk:wt add .../pull/2736crodas(SSH). The branch trackscrodas/fix/deactivate-vanished-keysets. Worktree at8415f1f5.crodaswith HTTPS, and a localfix/deactivate-vanished-keysetsthat tracksorigin/maincrodas. Branchcrodas-fix/deactivate-vanished-keysets.wt add .../pull/2710, from originorigin/meeting-agenda-2026-10-14. No call togh.wt prune --dry-run