Skip to content

feat: add wt pr command to create worktree from PR/MR number#2

Merged
vojtabiberle merged 2 commits intomasterfrom
pr_mr_support
Mar 3, 2026
Merged

feat: add wt pr command to create worktree from PR/MR number#2
vojtabiberle merged 2 commits intomasterfrom
pr_mr_support

Conversation

@vojtabiberle
Copy link
Copy Markdown
Owner

Summary

  • Adds git wt pr <number> to create a worktree from a GitHub PR or GitLab MR by number, instead of manually looking up the branch name
  • Auto-detects GitHub vs GitLab from the origin remote URL, resolves the branch via gh/glab CLI, fetches it, and delegates to cmd_add
  • Updates shell wrapper, completions (bash + zsh), help text, and man page

Closes #1

Test plan

  • git wt help shows the new pr command
  • git wt pr with no args shows usage error
  • git wt pr abc rejects non-numeric input
  • wt pr 1 on a GitHub repo fetches the PR branch and creates a worktree + auto-cd
  • Tab completion shows pr in subcommand list (bash and zsh)

Resolves #1. Adds `git wt pr <number>` which looks up the branch name
from a GitHub PR (via `gh`) or GitLab MR (via `glab`), fetches it,
and delegates to `cmd_add` for worktree creation and setup.
Add test infrastructure (test helper, CI workflow, Makefile targets) and
full test coverage for the new `wt pr` command including detect_forge
unit tests, argument validation, mock gh/glab integration, and shell
wrapper routing. Also add __GIT_WT_TESTING guard to support unit testing
of internal functions.
@vojtabiberle vojtabiberle merged commit 49e524e into master Mar 3, 2026
1 check passed
@vojtabiberle vojtabiberle deleted the pr_mr_support branch March 3, 2026 23:54
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.

feat: add support to create worktree from PR/MR

1 participant