diff options
author | Guilherme Vieira <guilherme@flipstudio.net> | 2017-10-22 15:53:36 -0200 |
---|---|---|
committer | Guilherme Vieira <guilherme@flipstudio.net> | 2017-10-31 19:22:40 -0200 |
commit | 1cc92dae77556a546951cc1f2988c11510eef2b1 (patch) | |
tree | c7bea81dc3c52006965247d5846f2307c1db61d4 /lib/gitlab/middleware | |
parent | e1122c9f6daff16b900a0837d25789e1e5bdc56c (diff) | |
download | gitlab-ce-1cc92dae77556a546951cc1f2988c11510eef2b1.tar.gz |
Returns a ssh url for go-get=1
Diffstat (limited to 'lib/gitlab/middleware')
-rw-r--r-- | lib/gitlab/middleware/go.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/middleware/go.rb b/lib/gitlab/middleware/go.rb index f42168c720e..cfc6b2a2029 100644 --- a/lib/gitlab/middleware/go.rb +++ b/lib/gitlab/middleware/go.rb @@ -4,6 +4,7 @@ module Gitlab module Middleware class Go include ActionView::Helpers::TagHelper + include Gitlab::CurrentSettings PROJECT_PATH_REGEX = %r{\A(#{Gitlab::PathRegex.full_namespace_route_regex}/#{Gitlab::PathRegex.project_route_regex})/}.freeze @@ -37,10 +38,20 @@ module Gitlab end def go_body(path) - project_url = URI.join(Gitlab.config.gitlab.url, path) + config = Gitlab.config + project_url = URI.join(config.gitlab.url, path) import_prefix = strip_url(project_url.to_s) - meta_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{project_url}.git" + repository_url = case current_application_settings.enabled_git_access_protocol + when 'ssh' + shell = config.gitlab_shell + port = ":#{shell.ssh_port}" unless shell.ssh_port == 22 + "ssh://#{shell.ssh_user}@#{shell.ssh_host}#{port}/#{path}.git" + when 'http', nil + "#{project_url}.git" + end + + meta_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}" head_tag = content_tag :head, meta_tag content_tag :html, head_tag end |