Repository navigation
test(switch): cover GitLab fork remote lookup across ssh/https - #2596
Merged
Merged
Conversation
The TODO at the GitLab fork-target lookup site warned that `find_remote_by_url` would fail when glab's git_protocol setting disagreed with the user's remote (ssh vs https). That concern is obsolete: `find_remote_by_url` parses both URLs into (host, owner, repo) via `GitRemoteUrl::parse` and matches on the parsed components, so transport protocol no longer affects lookup. Replace the TODO with a brief comment pointing to a new test that locks in the cross-protocol behavior, so future readers don't re-introduce the "try the other protocol" fallback. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
May 4, 2026
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.
Summary
The TODO at
src/commands/worktree/switch.rs:226-236warned thatfind_remote_by_urlcould fail when glab'sgit_protocolsetting (ssh vs https) disagreed with how the user's remote is configured, and suggested adding a fallback that converts ssh ↔ https and retries.That concern is obsolete:
find_remote_by_urlparses both URLs (the lookup target and each configured remote) into(host, owner, repo)viaGitRemoteUrl::parse, then matches on those components. Transport protocol is abstracted away before matching, so a remote configured with[email protected]:foo/bar.gitalready matches a lookup withhttps://gitlab.com/foo/bar.gitand vice versa.Implementing the literal fallback would have been dead code (the first lookup already succeeds across protocols). Instead:
test_find_remote_by_url_cross_protocol(noinsteadOfinvolved) to lock in the cross-protocol behavior so future readers don't re-introduce the fallback.Test plan
cargo run -- hook pre-merge --yes(3485 tests pass, lints clean)test_find_remote_by_url_insteadofstill passes