go-imports with SSH git URLs
Summary
GitLab supports the go get
command with a go-import
META tag. But it only shows HTTPS clone URLs, even if cloning via HTTPS is disabled.
Steps to reproduce
Example URL (view source): https://gitlab.com/gitlab-org/gitlab-ce?go-get=1
What is the current bug behavior?
That URL outputs the following HTML:
<!DOCTYPE html><html><head><meta content='gitlab.com/gitlab-org/gitlab-ce git https://gitlab.com/gitlab-org/gitlab-ce.git' name='go-import'></head></html>
This is the correct behaviour for gitlab.com because gitlab.com has HTTPS clone enabled.
But I tested on a GitLab installation with "Enabled Git access protocols" set to "Only SSH" and the output was the same.
In a hypothetical example where gitlab.com disabled HTTPS cloning, go get gitlab.com/gitlab-org/gitlab-ce
would fail because it's showing the wrong URL.
What is the expected correct behavior?
When HTTPS clone is disabled, GitLab should generate this output:
<!DOCTYPE html><html><head><meta content='gitlab.com/gitlab-org/gitlab-ce git git@gitlab.com:gitlab-org/gitlab-ce.git' name='go-import'></head></html>
(It would be nice if there was also an option to show SSH URLs without disabling HTTPS git access entirely).
Possible fixes
The code which generates this page is here:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/middleware/go.rb#L39-46