Repository navigation
Conversation
When the origin remote uses a ~/.ssh/config alias, such as git@github-work:acme/app.git for a second GitHub account, the inferred repository became https://github-work/acme/app.git. Resolve the alias with `ssh -G` (which reads ssh config without connecting) for SSH remotes whose host isn't a known provider host, and map GitHub, GitLab and Bitbucket SSH-over-443 hosts back to their main host.
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.
Summary
render ea blueprints createinfers the repository from theoriginremote when--repois omitted. If that remote uses an SSH host alias from~/.ssh/config, which is the usual setup for people with more than one GitHub account, the inferred URL uses the alias as the host:This change resolves the alias with
ssh -G <host>(it prints the effective config without connecting) for SSH remotes whose host isn't alreadygithub.com,gitlab.comorbitbucket.org. If the resolved HostName is one of the providers' SSH-over-443 hosts (ssh.github.com,altssh.gitlab.com,altssh.bitbucket.org), it maps back to the main host. Ifsshisn't available or fails, the remote is used unchanged, so behavior only changes for aliases that resolve. Explicit--repovalues are not touched, and hosts starting with-are never passed tossh.Motivation
I hit this reading the new repo/branch inference in
pkg/blueprint/git.go; no existing issue.How to verify
go test ./pkg/blueprint/ -run TestBuildCreateRequestResolvesSSHHostAlias -v: new table test covering an scp-style alias, anssh://alias with a port, an alias forssh.github.com, a known provider host (not passed to ssh), an unresolvable host, and an HTTPS origin.sshHostnameis a variable so the test doesn't depend on the machine's ssh config.buildCreateRequestcall with origingit@github-work:acme/app.gitreturnshttps://github-work/acme/app.git.sshHostnameby hand:git.example.comresolves to itself, and-oProxyCommand=xis rejected before calling ssh.go test ./cmd/... ./pkg/... ./internal/...passes;go vetandgofmtare clean. I didn't havegolangci-lintlocally.Release notes