Skip to content

FR: wt switch <github pull request url> #2896

Closed

Description

@thiagowfx

Hello Max, thank you for developing worktrunk, I've been loving it!

I have a small feature request.

Currently, wt switch supports wt switch pr:123 as a shortcut to check out a GitHub Pull Request.

For better ergonomics, it would be very handy if it could also support, as an example, wt switch https://github.com/max-sixty/worktrunk/pull/2895, which should be equivalent to wt switch pr:2895.

The current behavior is the following:

x wt switch https://github.com/max-sixty/worktrunk/pull/2895
✗ No branch named https://github.com/max-sixty/worktrunk/pull/2895
↳ To create a new branch, run wt switch --create 'https://github.com/max-sixty/worktrunk/pull/2895'; to list branches, run wt list --branches --remotes (last fetched 13m ago)

Personally, I use this pattern quite often. It is the only feature I am missing in worktrunk so far (after migrating from a custom wt script I've been using before discovering worktrunk).

I would be happy to take a stab at implementing it and sending out a PR if you think it is desirable and makes sense.

Activity

  1. worktrunk-bot commented on May 25, 2026

    @worktrunk-bot
    Collaborator

    Thanks for the kind words and the suggestion! I searched the codebase and confirmed there's no URL-aware parsing on the wt switch argument today — only the pr:{N} / mr:{N} literal prefixes are recognized. The current behavior you see is the regular branch-resolution path treating the URL as a branch name.

    A few notes for whoever picks this up:

    • The PR-shortcut entry points are resolve_switch_target (for the positional arg) and resolve_base_ref (for --base), both in src/commands/worktree/switch.rs. They strip the pr: / mr: prefix then dispatch to the forge providers — a URL match would slot in at the same place.
    • For symmetry, GitLab MR URLs (https://gitlab.com/owner/repo/-/merge_requests/N) and GitHub Enterprise hosts probably want the same treatment. Worktrunk already handles non-github.com GitHub hosts in the forge layer (see #1408).
    • This would likely also extend naturally to --base https://.../pull/N.

    I'll leave it for a maintainer to confirm they'd accept the feature before you spend time on a PR.

  2. max-sixty commented on May 25, 2026

    @max-sixty
    Owner

    yes, good idea, let's do this @worktrunk-bot.

    have it as just a parenthetical in the docs pls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions