fix(cmdutils): say how to set ssh_host when a remote is on a subdomain of a logged-in host
Description
In a clone whose SSH remote is on an instance's separate SSH host, such as ssh.gitlab.gnome.org for gitlab.gnome.org, repository commands fail when ssh_host is unset. The error says to run glab auth login, which doesn't help if you already have.
When an SSH remote host is a subdomain of a configured host, the error now names the command that links them, instead of suggesting glab auth login. glab doesn't map such a remote by itself, since the subdomain may be a separate instance (see #8707). Before:
none of the git remotes configured for this repository point to a known GitLab host. Please use `glab auth login` to authenticate and configure a new host for glab.
Configured remotes: ssh.gitlab.gnome.org.After:
none of the git remotes configured for this repository point to a known GitLab host.
If ssh.gitlab.gnome.org is the SSH host of gitlab.gnome.org, run:
glab config set ssh_host ssh.gitlab.gnome.org --host gitlab.gnome.org
Configured remotes: ssh.gitlab.gnome.org.HTTPS remotes get no hint. A subdomain in an HTTPS remote is a separate web address, and so most likely a separate instance, and setting ssh_host to it would send that remote's requests to the parent host. Errors without a hint are unchanged.
Related Issues
Part of #8707.
How has this been tested?
New cases in Test_remoteResolverErrors:
- Two SSH remotes on
ssh.my-gitlab.orggive one hint for the configuredmy-gitlab.org. - An SSH remote on
notmy-gitlab.orggives no hint. - An HTTPS remote on
dev.my-gitlab.orggives no hint. - With both
my-gitlab.organdgitlab.my-gitlab.orgconfigured,ssh.gitlab.my-gitlab.orgis matched togitlab.my-gitlab.org.
Also:
- In a clone of
GNOME/gnome-settings-daemon(remotegit@ssh.gitlab.gnome.org:...,ssh_hostunset),glab issue listprints the error above. Running the suggested command in a copy of the config makesglab issue listlist the issues. go test ./internal/cmdutils/,make test-changedandgolangci-lint run ./internal/cmdutils/...pass. The comment-overlap gate reports nothing for the new code.