Welcome to mirror list, hosted at ThFree Co, Russian Federation.

repository_url_builder.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed9a298ee8cafef7db2bd856b61f2561a0150c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Gitlab
  module RepositoryUrlBuilder
    class << self
      def build(path, protocol: :ssh)
        case protocol
        when :ssh
          ssh_url(path)
        when :http
          http_url(path)
        else
          raise NotImplementedError, "No URL builder defined for protocol #{protocol}"
        end
      end

      private

      def ssh_url(path)
        Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
      end

      def http_url(path)
        root = Gitlab::CurrentSettings.custom_http_clone_url_root.presence || Gitlab::Routing.url_helpers.root_url

        Gitlab::Utils.append_path(root, "#{path}.git")
      end
    end
  end
end