Repository navigation
Look a repository up on the host an SSH alias stands for - #166
Open
ammartahamohamedy wants to merge 1 commit into
Open
ammartahamohamedy wants to merge 1 commit into
ammartahamohamedy wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #165
Problem
The CLI looked a repository up by the host its remote names, while Git connects through SSH, which resolves
Hostaliases. A remote likegit@github-work:acme/web.git, or agithub.comremote thaturl.<alias>.insteadOfrewrites to one, senthost=github-work, so every repository command and every hook review got404: repository not found. Hooks have no--repoto work around it.Fix
lib.rssource(), both lookup call sites). The repository is looked up on the remote's own host, as before. Only when that returns 404 for an ssh or scp-style remote does the CLI ask SSH for the host it connects to, and look there.Host github.com→HostName ssh.github.com,Port 443), and runssshonly on the failure path.--source-providernames one, so an alias for gitlab.com is looked up as GitLab.git::ssh_host(host)runsssh -G -- <host>and returns itshostname(with a non-22port, asparsewrites hosts) only when it differs fromhost.ssh.github.comcounts asgithub.com.ssh, a non-zero exit, a missing or malformedhostname, or the 5-second timeout means no second lookup.-is never passed tossh, and--comes first. Stdin and stderr are closed.RemoteRepositorygains ansshflag, set byparseforssh://and scp-style URLs; parsing is otherwise unchanged.looked up acme/web on host github-work and on host github.com, its SSH host: … returned HTTP 404: repository not found, or just the one host when SSH resolves nothing. That covers whatssh -Gcan't resolve: an alias that onlycore.sshCommand -For PuTTY knows, or a repository that isn't connected. Other errors are unchanged.Tests (written first; failed before the change)
git::tests::an_ssh_alias_reads_as_the_host_ssh_connects_to(new)ssh -Goutput: an alias becomes itshostname, a non-22 port is kept,ssh.github.comon 443 isgithub.com, a host that is no alias resolves to nothing (whatever port SSH uses), and output with no usable host (missing, empty, option-like, whitespace, a path) resolves to nothinggit::tests::ssh_is_never_asked_about_a_host_that_reads_as_an_option(new)-resolves to nothinggit::tests::reads_owner_and_name_from_remote_urls(extended)sshflag: set forssh://, unset forhttps://ssh_over_port_443_keeps_the_github_com_lookup(new,tests/hooks.rs, Unix)github.com→ssh.github.com:443in a stand-inssh, agit@github.com:remote is reviewed andsshis never runan_ssh_host_alias_is_looked_up_on_the_host_it_stands_for(new, Unix)ssh.github.com:443and aninsteadOfrewrite, andreview --repo git@github-work:…does tooa_repository_missing_on_both_hosts_names_both(new, Unix)findings --pr; the console sees exactly those two lookups, the second for a gitlab.com alias as GitLaba_repository_the_console_cannot_find_is_named_with_its_host(new)findings --prThe hooks stand-in console now answers 404 for a host other than github.com, as the real console does, instead of failing an assertion; existing tests are unaffected.
Mutation checks: each of these fails a test: ignoring SSH's port, resolving a host that is no alias, accepting a
hostnamewith a path, keepingssh.github.comas is, marking every remote as SSH, dropping the 404 context, no SSH fallback, a second lookup that asks for the alias again, not re-guessing the provider, and a 404 that names only one host.Checks
cargo fmt --check: ✅cargo clippy --locked --all-targets -- -D warnings: ✅ on Linux (Debian, 1.100.0). On Windows it stops at the 2 errorsmainalready has there (src/agent/tests.rs).cargo test --locked: ✅ on Linux, every suite passes (175 tests, 1 ignored as onmain). On Windows, the same 12 failures as onmain(tests/mcp.rs×7,agent_install×2,update,local_patch,hookson a Windows push URL); the three Unix-only tests don't run there.After rebasing onto
16a230f: the same results, exceptsetup::tests::setup_brief_commands_are_available_in_this_release, which fails on clean16a230ftoo (Linux and Windows), so it isn't from this change.cargo deny check: no dependency changes.End to end (Linux, a throwaway SSH config read by real OpenSSH, a stand-in console that knows
acme/webonly ongithub.com), upstream430cb44→ this branch:review --pr 7ongit@github-work:acme/web.gitgithub-work404, then found on github.comcould not review … 404git@github.com:…rewritten to the alias byinsteadOfcore.sshCommand -Fknowslooked up acme/web on host github-othergit@github.com:…with GitHub's SSH over port 443 configuredsshnot runFork CI: ✅
checkandwindowspass on ammar-taha-dev/proofline-cli#9.Overlaps: #130 and #163 each add a second
get-url+parselookup (remote_repository_in);parsenow sets thesshflag their repositories carry, so a lookup of them throughsource()gets the fallback. No textual conflict.Proofline review log
Fork review PR: ammar-taha-dev/proofline-cli#9. Rounds capped at 2.
src/init.rs(proofline init): the install address is printed raw, and anullor non-HTTPS primary address skips the fallback16a230f: after the rebase the fork'smainstill sat at430cb44, so the fork PR showed upstream's new commits too. Nothing in this change touchesinit.rsmainwas synced, and both are noted for separate issuesThe prompts below are the ones that drove this implementation; the investigation, reproduction and fix scope were done before them and aren't included.