Repository navigation
fix(switch): use a GitHub PR URL's host for gh api - #4722
Merged
Merged
Conversation
wt switch on a GitHub /pull/N URL asked gh's default host. An Enterprise URL against a github.com remote then 404'd even when gh was logged into the URL's host. A configured forge.hostname still wins. Otherwise that URL host is passed as gh api --hostname when gh has a login there, then the GitHub remote's host. pr:N is unchanged. Refs max-sixty#4709
worktrunk-bot
left a comment
Collaborator
There was a problem hiding this comment.
The new integration test copies test_switch_pr_enterprise_remote_passes_hostname almost line for line, and its github.com-remote setup isn't the case where the URL host matters most. Details are inline, along with a small fix where a code comment overstates the precedence.
…mote The URL-host test repeated the enterprise-remote test; both are now cases of one test. The URL cases use an SSH-alias origin (git@github-work:…) so the authed case passes only when the URL host is tried before the remote host. Only a GitHub /pull/N URL carries a host; mr:N now passes None. The precedence comment says the URL host wins only when it isn't github.com.
worktrunk-bot
approved these changes
Nov 6, 2026
1 task
max-sixty
pushed a commit
that referenced
this pull request
Nov 21, 2026
When a GitHub Enterprise PR lookup has no selected API hostname, a 404 only points at `gh repo set-default`. That can already be correct even though `gh api` used its default host. For a 404 on an explicit Enterprise PR URL, when no API host was selected, the hint names the host for `gh auth login` and points to `forge.hostname` if the API host differs. Short PR references keep the ordinary 404 hint because a Git remote can use an SSH alias. Host selection itself stays as in #4710 and #4722. Checked with the 107 switch PR integration tests, including the new URL, remote, and configured-host cases, and with rustfmt, all-target/all-feature Clippy, doctests, and documentation generation. The full pre-merge hook could not complete locally because `pre-commit` and `cargo insta` were unavailable. The tests use a stub `gh` and do not require an Enterprise account. Refs #4709 AI assistance was used for the patch and tests. Review follow-up: the SSH alias and missing-login cases reproduced against the previous head. All 104 matching switch integration tests, all-target/all-feature Clippy, rustfmt, documentation generation, and doctests passed. The full local pre-merge hook still lacks `pre-commit` and `cargo insta`. --------- Co-authored-by: xunguangzlj-cloud <[email protected]> Co-authored-by: worktrunk-bot <[email protected]>
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 switch https://host/owner/repo/pull/Naskedgh apiwith no--hostname, so the lookup went to gh's default host. An Enterprise URL then 404'd when the git remote was github.com, even though gh was logged in on the URL's host.When
forge.hostnameis unset, the/pull/NURL's host is now passed as--hostnameifgh auth tokensucceeds for it.pr:Nstill follows the remote, and the 404 hint is unchanged.Checked with the new switch cases (logged in and not), the existing enterprise-remote regression, the URL-host unit test,
cargo test --doc, andcargo clippy --all-targets --all-features -- -D warnings.Refs #4709