Repository navigation
feat: add github enterprise hostname parsing to wt switch logic - #1408
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Nice fix — GHE users would silently get 404s or auth errors without --hostname. The implementation reuses existing APIs well.
One suggestion to avoid recreating a Repository that already exists at the call site, and a note about GitLab parity.
|
thanks @TomRomeo , looks good! |
|
|
Investigated both questions: Where else should
|
The bot pushed a branch to upstream before realizing PR #1408 was from a fork, then had to delete it. Add guidance to check headRepositoryOwner before pushing, and avoid referencing SHAs from deleted branches. Closes #1411 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@worktrunk-bot please respond to the comments above (for others: still working through why it seems to work for comments but not inline comments: #1426) |
|
Responded to both inline threads:
|
|
thanks @TomRomeo ! |
The `fetch_info` example still referenced `repo_root` after #1408 changed the signature to accept `&Repository`. Closes #1461 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
wt switch pr:<number>for repositories hosted on GitHub Enterprise (or other non-github.comhosts) by passing--hostnameto theghCLIGitRemoteUrl::parse()utility, falling back togithub.comif the URL can't be parsedProblem
When checking out a PR in a repository hosted on a GitHub Enterprise instance (e.g.,
github.example.com), thegh apicall infetch_pr_infodid not specify which host to authenticate against. TheghCLI defaults togithub.com, so PR checkout silently failed for any other GitHub host.The
gh apicommand accepts a--hostnameflag to target a specific GitHub host, but it was not being used.Solution
This PR extracts the hostname from the repository's configured remote URL and passes it to
gh api --hostname. The extraction is best-effort so if the remote URL can't be parsed for any reason, it falls back to"github.com", preserving the existing behavior.The hostname parsing reuses the existing
GitRemoteUrl::parse()to support all remote URL formats (https://,ssh://,git@,git://,http://).Notes
I'm not that experienced in Rust, so I'm happy to implement any PR feedback and add tests if necessary.