You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Open a pull request from a pane: the web address is wrong when the remote address uses a host alias of the SSH configuration (git@github-work:owner/repo.git) #576
In a pane, the pointer over a reference such as PR 2510 shows the chips "Open PR 2510" and "Preview". "Preview" works, and ⌘-click works. But a click on "Open PR 2510" opens nothing, because the address is wrong:
https://github-work/acme/app/pull/2510
The right address is https://github.com/acme/app/pull/2510.
This happens when the remote address of the repository uses a host alias of the SSH configuration. A developer with two GitHub accounts (a personal one and the one of a client) often writes in ~/.ssh/config:
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_work
and clones with git@github-work:acme/app.git. Git and gh read the SSH configuration, so they find github.com. Heidrun does not.
The cause
remoteToWeb in refs.ts turns git@github-work:acme/app.git into https://github-work/acme/app: it takes the host of the remote address as it is. The same function is used by webOfRemote, so every web address built from the remote address is wrong: the issues, the pull requests, the merge requests, the commits, and the branches.
"Preview" works because it calls gh, which reads the SSH configuration.
Two more effects of the same cause:
The hosting service is found with host.includes("github"). The alias github-work contains "github" by chance. An alias such as work or client is read as GitLab, so the paths of the addresses (/-/merge_requests/) and the icon of the Code hosting sidebar section are wrong too.
The click calls openUrl(...).catch(() => {}), so a failure is silent: the developer clicks and nothing happens, with no message.
The fix
In the Tauri command project_refs of project.rs, when the remote address is an SSH address (user@host:path or ssh://), resolve the host with ssh -G <host> and read its line hostname. Return the real host next to the remote address. ssh -G only reads the configuration, and does not connect. Keep the answer for each host, as the context of the references is kept today.
remoteToWeb and webOfRemote use the real host. The hosting service is found from the real host.
An HTTPS address is not changed.
When ssh -G fails, or ssh is not installed, keep the host as it is, as today.
A failure of openUrl shows an error notification with the address, instead of nothing.
Today the field repo of .heidrun/config.json already overrides the remote address, so a developer can write "repo": "https://github.com/acme/app" as a workaround. Say it in the documentation of the field.
code_hosting.md: "Heidrun finds the hosting service from the remote address only, with no call to gh or glab". The rule stays true, and adds that the host of an SSH address is resolved with ssh -G.
Tests
project.rs: a fake SSH configuration in a temporary folder (ssh -F <file> -G <host>) with an alias to github.com and an alias to a GitLab host, an HTTPS address, and a host that has no alias.
refs.test.ts: remoteToWeb and webOfRemote with a real host given, for an alias that contains "github" and for an alias that does not.
A click on "Open" whose openUrl fails shows the error notification.
Activity