Repository navigation
Simplify forge detection with [forge] config section - #1826
Merged
Merged
Conversation
Replace the hostname-centric forge detection spec with a design that derives owner/repo from URL paths instead of hostnames. This fixes SSH host alias setups (e.g., github-personal) without requiring url.insteadOf. Key design changes: - Only pass --hostname to gh/glab when forge.hostname is configured - Match remotes by owner/repo, with host as disambiguator only - New [forge] config section (platform + hostname), deprecating ci.platform - Document SSH alias behavior matrix (what works vs. needs config) Co-Authored-By: Claude <[email protected]>
Stop deriving API hostname from remote URLs — SSH host aliases corrupt
the host but never the path. Extract owner/repo from the raw remote URL
and build literal API paths. Only pass --hostname to gh when
forge.hostname is explicitly configured.
- Add [forge] config section with platform and hostname fields
- forge.platform falls back to ci.platform (deprecated) for compat
- fetch_pr_info: literal repos/{owner}/{repo}/pulls/{n} path, no
--hostname unless forge.hostname configured
- github_owner_repo: extract directly from primary remote
- detect_github_commit_checks: config-only --hostname
- find_remote_for_repo callers: pass None for host (owner/repo match)
- resolve_same_repo_ref: match by owner/repo, not host
- [ci] → [forge] deprecation with migration support
- Fix config show duplicate warnings for deprecated section keys
Closes #1790
Co-Authored-By: Claude <[email protected]>
# Conflicts: # src/commands/worktree/switch.rs
Platform detection now checks the primary remote's effective URL instead of searching all remotes. Users with opaque SSH aliases use `forge.platform` config. Co-Authored-By: Claude <[email protected]>
`platform_for_repo` now loads config internally instead of taking a
`platform_override` parameter — callers no longer pre-extract it.
`from_branch_ref` uses `split_once('/')` instead of iterating
`all_remote_urls()`, removing the `repo` parameter and a git call per
branch.
Co-Authored-By: Claude <[email protected]>
worktrunk-bot
previously approved these changes
Mar 31, 2026
worktrunk-bot
left a comment
Collaborator
There was a problem hiding this comment.
codecov/patch failed — several new lines in the deprecation module lack test coverage.
Actionable gaps (new code from this PR):
src/config/deprecation.rs:find_ci_section_deprecationandmigrate_ci_to_forgehave untested edge-case branches (parse failure,[forge]already exists, no platform value). Theformat_deprecation_warningspath forci_section: trueis also uncovered.src/commands/list/ci_status/github.rslines 18–22: rewrittengithub_owner_repousing primary remote (hard to test withoutghCLI).src/git/remote_ref/github.rsandgithub.rs: the--hostnameextension paths forforge.hostnameconfig.
The deprecation unit tests are the most straightforward to add — happy path is tested via integration snapshots, but the edge-case branches need direct unit tests. I can push a commit adding those tests if you'd like.
worktrunk-bot
dismissed
their stale review
March 31, 2026 02:46
codecov/patch failed — new deprecation code needs test coverage
Co-Authored-By: Claude <[email protected]>
The example in `wt config --help` still showed the old `[ci]` section. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
added a commit
that referenced
this pull request
Apr 1, 2026
Convert intra-doc links that reference binary crate paths (platform_for_repo, github_owner_repo) and unresolvable associated methods (find_remote_for_repo) to plain code references. These links were introduced in #1826 and fail `cargo doc` because the targets are either in the binary crate or not resolvable from module-level docs. Co-Authored-By: Claude Opus 4.6 <[email protected]>
2 tasks done
worktrunk-bot
added a commit
that referenced
this pull request
Apr 1, 2026
The existing `cargo doc --no-deps` check missed broken links in #1826 because most items in this binary crate are `pub(crate)`. Adding `--document-private-items` ensures all intra-doc links are validated. Co-Authored-By: Claude Opus 4.6 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 1, 2026
SSH host aliases (`git@work-ssh:owner/repo`) corrupt the hostname in
remote URLs but never the path. The previous forge detection code tried
to work around this by searching all remotes, auto-detecting GHE
hostnames, and maintaining multiple resolution strategies. This PR
replaces all of that with a simpler design: derive owner/repo from URL
paths, and let users set `forge.platform` / `forge.hostname` for corner
cases.
## Key changes
**New `[forge]` config section** with `platform` and `hostname` fields.
`ci.platform` is deprecated with migration support. Example configs and
inline help examples updated.
**`fetch_pr_info`** now builds literal API paths from the primary
remote's raw URL instead of relying on `gh`'s placeholder resolution.
`--hostname` only passed when explicitly configured.
**`platform_for_repo`** checks config > branch's remote > primary
remote. No longer searches all remotes. Loads config internally instead
of taking a `platform_override` parameter.
**`find_remote`** matches by owner/repo only (no host required),
handling SSH aliases where the local hostname differs from the API
hostname.
**`CiBranchName::from_branch_ref`** uses `split_once('/')` instead of
iterating `all_remote_urls()`, removing a git call per branch during `wt
list`.
## Deleted
- `resolve_gh_hostname` (GHE auto-detection heuristic)
- `find_forge_remote` (search all remotes by predicate)
- `all_remote_urls()` loop in branch name parsing
- `platform_override` parameter threading through callers
The spec in `src/git/repository/remotes.rs` documents the full design.
> _This was written by Claude Code on behalf of max-sixty_
---------
Co-authored-by: Claude <[email protected]>
This was referenced Apr 2, 2026
max-sixty
added a commit
to mikeyroush/worktrunk
that referenced
this pull request
May 11, 2026
Adds Azure DevOps as a third forge alongside GitHub and GitLab: - `wt switch pr:N` dispatches to GitHub or Azure DevOps automatically based on the repo's configured remotes (GitHub still wins in mixed-remote setups). - `wt list --full` surfaces Azure DevOps PR and pipeline status via the `az` CLI. - `forge.platform` accepts `azure-devops` as an override. - `wt config show --full` reports `az` install/auth state when the platform is detected as Azure DevOps. Implementation notes: - New `AzureDevOpsProvider` implements `RemoteRefProvider`; auto-detects the organisation from any Azure DevOps remote URL so contributors don't have to pass `--org`. - `GitRemoteUrl` learns `is_azure_devops()`, `azure_organization()`, and `azure_project()` to parse `dev.azure.com`, `ssh.dev.azure.com`, and legacy `*.visualstudio.com` URLs (which don't fit the standard host/owner/repo shape). - Pipeline URLs are constructed from org/project/build ID rather than the API's `url` field (which is a REST endpoint, not a browser URL). - Requires the `azure-devops` extension (`az extension add --name azure-devops`). Originally proposed by @mikeyroush in max-sixty#1256; reimplemented against current `main` to pick up the `[forge]` config section (max-sixty#1826), `url.insteadOf` fallback (max-sixty#1771), and `handle_switch` consolidation (max-sixty#2597) that landed after the original branch. Co-Authored-By: mroush <[email protected]> Co-Authored-By: Claude <[email protected]>
max-sixty
pushed a commit
that referenced
this pull request
Nov 5, 2026
… is logged in to it (#4710) `gh api` doesn't take its host from the repository. Without `--hostname` it uses gh's default host, which is github.com once more than one host is logged in. `fetch_pr_info` passed `--hostname` only when `forge.hostname` was set, so on a GitHub Enterprise remote `wt switch pr:N` and `wt switch <PR URL>` asked github.com for the PR and got a 404. With no `forge.hostname`, the lookup now passes the GitHub remote's host as `--hostname` if `gh auth token --hostname <host>` succeeds (a local check, no network; `choose_pr_forge` already uses the same check). An SSH alias such as `github-personal` has no gh login, so it still goes to gh's default host. That keeps the #1790 fix in place, the one #1826 made by removing host detection. A configured `forge.hostname` still takes priority. github.com remotes skip the check, so they behave as before. `test_switch_pr_enterprise_remote_passes_hostname` uses an `https://github.example.com/...` remote and a mock `gh`. When `gh` is logged in to that host, the test expects `--hostname github.example.com` on the `api` call; it failed before this change and passes now. When `gh` isn't logged in to it, the test expects no `--hostname` flag. The existing `pr` integration tests pass. Not changed here: the issue's second suggestion, a 404 hint that names `forge.hostname`. That case still applies when `gh` has no login for the Enterprise host. Whether to add that output is up to a maintainer. A PR URL's own host is also not used yet. In the reported setup the remote's host matches the URL's, so this change fixes that case. Refs #4709 — automated triage 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.
SSH host aliases (
git@work-ssh:owner/repo) corrupt the hostname in remote URLs but never the path. The previous forge detection code tried to work around this by searching all remotes, auto-detecting GHE hostnames, and maintaining multiple resolution strategies. This PR replaces all of that with a simpler design: derive owner/repo from URL paths, and let users setforge.platform/forge.hostnamefor corner cases.Key changes
New
[forge]config section withplatformandhostnamefields.ci.platformis deprecated with migration support. Example configs and inline help examples updated.fetch_pr_infonow builds literal API paths from the primary remote's raw URL instead of relying ongh's placeholder resolution.--hostnameonly passed when explicitly configured.platform_for_repochecks config > branch's remote > primary remote. No longer searches all remotes. Loads config internally instead of taking aplatform_overrideparameter.find_remotematches by owner/repo only (no host required), handling SSH aliases where the local hostname differs from the API hostname.CiBranchName::from_branch_refusessplit_once('/')instead of iteratingall_remote_urls(), removing a git call per branch duringwt list.Deleted
resolve_gh_hostname(GHE auto-detection heuristic)find_forge_remote(search all remotes by predicate)all_remote_urls()loop in branch name parsingplatform_overrideparameter threading through callersThe spec in
src/git/repository/remotes.rsdocuments the full design.