issue-287: forgejo: detect ssh:// remotes #288

Merged
david merged 1 commit from bug/issue-287/forgejo-detect-ssh-remotes into main 2026-10-03 20:38:07 +00:00
Owner

parseRemoteUrl in the forgejo extension only matched http(s):// URLs and the SCP-style git@host:owner/repo form. ssh://-style remotes — a very common way of configuring origin, e.g. ssh://git@host/owner/repo.git, or ssh://git@host:2222/owner/repo with an explicit port — matched neither branch and produced:

Forgejo error (command_failed): Unable to parse remote URL: ssh://git@…

…which made every tool relying on auto-detection fail (forgejo_detect, issues, PRs, Actions).

What changed

  • Scheme-prefixed remotes (http://, https://, ssh://, git://) are now parsed with the WHATWG URL parser, which also discards embedded user:token@ credentials (replacing the manual strip).
  • New apiScheme()/apiHost() helpers derive the API host: http/https keep their own scheme and port (e.g. http://localhost:3000), while ssh/git remotes map to https:// with the transport port dropped — the :2222 in an ssh:// URL is the SSH port, not the API port.
  • The SCP-form regex is kept as a fallback for git@host:owner/repo (its host character class is now [^:/]+).
  • All previously-supported forms parse exactly as before; the full jest suite (262 tests) is green and tsc builds clean. A live probe of 7 remote forms confirms the new behaviour.

Per-file breakdown

  • Modified extensions/forgejo/src/git.ts — replaced the two regex branches (http(s) match + git@ match with manual token strip) in parseRemoteUrl with the URL-first parse, the apiScheme/apiHost helpers, and the SCP fallback; updated the doc comment to list the supported forms.
  • Modified extensions/forgejo/tests/git.test.ts — renamed the existing SCP test to disambiguate; added 3 parseRemoteUrl tests: ssh:// full-URL form, transport-port dropped from the API host, and embedded-token stripped from an ssh:// URL.

Closes #287

`parseRemoteUrl` in the `forgejo` extension only matched `http(s)://` URLs and the SCP-style `git@host:owner/repo` form. `ssh://`-style remotes — a very common way of configuring `origin`, e.g. `ssh://git@host/owner/repo.git`, or `ssh://git@host:2222/owner/repo` with an explicit port — matched neither branch and produced: ``` Forgejo error (command_failed): Unable to parse remote URL: ssh://git@… ``` …which made every tool relying on auto-detection fail (`forgejo_detect`, issues, PRs, Actions). **What changed** - Scheme-prefixed remotes (`http://`, `https://`, `ssh://`, `git://`) are now parsed with the WHATWG `URL` parser, which also discards embedded `user:token@` credentials (replacing the manual strip). - New `apiScheme()`/`apiHost()` helpers derive the API host: http/https keep their own scheme **and** port (e.g. `http://localhost:3000`), while ssh/git remotes map to `https://` with the transport port **dropped** — the `:2222` in an `ssh://` URL is the SSH port, not the API port. - The SCP-form regex is kept as a fallback for `git@host:owner/repo` (its host character class is now `[^:/]+`). - All previously-supported forms parse exactly as before; the full jest suite (262 tests) is green and `tsc` builds clean. A live probe of 7 remote forms confirms the new behaviour. **Per-file breakdown** - **Modified** `extensions/forgejo/src/git.ts` — replaced the two regex branches (http(s) match + `git@` match with manual token strip) in `parseRemoteUrl` with the URL-first parse, the `apiScheme`/`apiHost` helpers, and the SCP fallback; updated the doc comment to list the supported forms. - **Modified** `extensions/forgejo/tests/git.test.ts` — renamed the existing SCP test to disambiguate; added 3 `parseRemoteUrl` tests: `ssh://` full-URL form, transport-port dropped from the API host, and embedded-token stripped from an `ssh://` URL. Closes #287
david merged commit e3d57b2993 into main 2026-10-03 20:38:07 +00:00
david deleted branch bug/issue-287/forgejo-detect-ssh-remotes 2026-10-03 20:38:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-extensions-and-skills!288
No description provided.