Repository navigation
fix(git): stop reading a remote URL's port as part of the repository path - #16723
Conversation
…path The SCP-shorthand branch ran before the URL parser, and its regex matches a URL that already carries a scheme, so the port in `ssh://git@host:2222/owner/repo.git` was consumed as the first path segment and `repository` came back as `2222/owner/repo`. Skip the shorthand branch when the URL contains a scheme and let the existing `new URL()` branch handle it. Plain `git@host:owner/repo` shorthand is unchanged.
The overview section already covers a self-hosted forge's port over https and an ssh shorthand remote, but never the two together, which is the combination that produced a wrong href.
…path Restores the parser change, which was dropped from the previous commit. The SCP-shorthand branch ran before the URL parser, and its regex matches a URL that already carries a scheme, so the port in `ssh://git@host:2222/owner/repo.git` was consumed as the first path segment and `repository` came back as `2222/owner/repo`.
|
🚦 CI is currently failing on this PR's latest commit. Please fix the failing checks before OpenHands reviews it - this is re-checked automatically once you push a new commit. (A maintainer can also request This is an automated check - no AI was used to generate this comment. |
|
All functional checks pass on this PR:
"touches frontend code but the description has no screenshot or video." The change is to That file already covered a self-hosted forge's port over
Glad to restructure the issue or this PR if you would rather it read a different way. |
Guarding the shorthand branch on `://` keeps the port out of the repository path, but it also sends every scheme'd URL whose colon segment is not numeric into `new URL()`, which throws: `ssh://git@host:owner/repo` and `git+ssh://git@host:owner/repo` went from parsing to returning null, which drops the browse link and, through use-local-git-info, the repo and provider that git-control-bar gates its actions on. Ordering the two parsers instead handles both shapes in one branch, and also fixes IPv6 remotes, where the shorthand regex reduced the host of `ssh://git@[::1]:2222/owner/repo.git` to `[`. Cover the colon-segment-is-a-path case, split the credentials test into its http and https:// user:password forms, and name the git-sync test for the port behaviour it actually asserts.
VascoSch92
left a comment
There was a problem hiding this comment.
Thanks for the PR.
I just added a commit to fix a couple of nits.
Otherwise, LGTM
✅ Mock-LLM E2E Tests16/16 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
|
🚦 CI is currently failing on this PR's latest commit. Please fix the failing checks before OpenHands reviews it - this is re-checked automatically once you push a new commit. (A maintainer can also request This is an automated check - no AI was used to generate this comment. |
|
🚀 Released in v1.15.0. |
HUMAN:
Ran the parser test file on this branch, and all 13 cases pass. Put the version
of parse-git-remote-url.ts from main back, and the two new cases fail, showing
"2222/owner/repo" instead of "owner/repo".
What convinced me this is worth fixing is that the browse link in the git sync
panel is built directly from that value, so the port ends up in the URL you
click.
AGENT:
Ran the parser against remote URLs that carry an explicit port, before and after the change, on a clean
npm cicheckout.No regressions across the surrounding suites, same clean checkout:
Why the shorthand branch was claiming these URLs.
[^@\s]+happily matchesssh://git, sossh://[email protected]:2222/owner/repo.gitwas treated as SCP shorthand with hostgit.example.comand path2222/owner/repo.git:Component-level proof of the user-visible effect.
git-sync-overview-section.test.tsxalreadycovers a self-hosted forge's port over
httpsand ansshshorthand remote, but never the twotogether. Adding that case pins the rendered anchor's
href:That is the actual link a user clicks in the git sync panel, so the port was landing in the
navigation target.
Confirmed on a running stack, not just in tests. Captured from the real
/automations/git-syncroute against a local agent server
1.42.1/ automation backend1.8.0, health{"status":"ok"},git sync clean (no
last_error, no sync in progress, zero pending changes), with the repositoryconfigured as
ssh://[email protected]:2222/org/repo.git. Reading[data-testid="git-sync-repo-link"]live in the DOM:The rendered text is the configured remote either way, so the panel looks identical in a
screenshot. The change is the anchor's
href, which is why the evidence here is the DOM value andthe assertion above rather than an image.
User-visible effect.
git-sync-overview-section.tsx:32builds the browse link as`https://${parsed.host}/${parsed.repository}`. Read live from the running page, that anchor'shrefishttps://git.example.com/2222/org/repobefore the change andhttps://git.example.com/org/repoafter (screenshots above). That function's doc comment already states it keeps"non-default ports intact" and rebuilds
ssh://remotes "over https from the parsed host andrepository", so this makes the code match the documented intent.
use-local-git-info.ts:68surfaces
repositorydirectly, so the displayed repo name was wrong too.Plain
[email protected]:owner/repo.gitshorthand is unaffected and is covered by an existing test.Why
parseGitRemoteUrlread the port of a scheme'd remote URL as the first segment of the repositorypath, so anyone whose remote is a self-hosted forge on a non-default SSH port (2222, 7999) got a
wrong repository name and a broken "browse repository" link.
Summary
://, letting the existingnew URL()branchparse it.
__tests__/utils/parse-git-remote-url.test.tscoveringssh://with a port andhttp://with credentials and a port.git-sync-overview-section.test.tsxpinning the browse link'shreffor anssh://remote on a custom port.Issue Number
Fixes #16722
How to Test
13 cases pass. Reverting
src/utils/parse-git-remote-url.tstomainand re-running fails exactlythe two new cases with
expected '2222/owner/repo' to be 'owner/repo'.Video/Screenshots
Before (

main) — the anchor'shrefcarries the port as a path segment:After (this branch) — the port is gone from the

href; Chrome's status bar shows the resolved destination:The rendered link text is the configured remote in both, so the panel looks the same.
The change is the anchor's
href, visible in the DevTools Elements panel.