X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0eb72b526bf8bbb011551ecf019f604e17a534f1..0f537bcaa60b8a1496010bc9d4a943484e69081c:/services/api/app/models/repository.rb diff --git a/services/api/app/models/repository.rb b/services/api/app/models/repository.rb index 48655156c4..46f2de6ee4 100644 --- a/services/api/app/models/repository.rb +++ b/services/api/app/models/repository.rb @@ -49,7 +49,7 @@ class Repository < ArvadosModel # prefers bare repositories over checkouts. [["%s.git"], ["%s", ".git"]].each do |repo_base, *join_args| [:uuid, :name].each do |path_attr| - git_dir = File.join(Rails.configuration.git_repositories_dir, + git_dir = File.join(Rails.configuration.Git.Repositories, repo_base % send(path_attr), *join_args) return git_dir if File.exist?(git_dir) end @@ -92,28 +92,36 @@ class Repository < ArvadosModel end if not (/^#{prefix_match}[A-Za-z][A-Za-z0-9]*$/.match(name)) errors.add(:name, - "#{errmsg_start} a letter followed by alphanumerics") + "#{errmsg_start} a letter followed by alphanumerics, expected pattern '#{prefix_match}[A-Za-z][A-Za-z0-9]*' but was '#{name}'") false end end def ssh_clone_url - _clone_url :git_repo_ssh_base, 'git@git.%s.arvadosapi.com:' + _clone_url Rails.configuration.Services.GitSSH.andand.ExternalURL, 'ssh://git@git.%s.arvadosapi.com' end def https_clone_url - _clone_url :git_repo_https_base, 'https://git.%s.arvadosapi.com/' + _clone_url Rails.configuration.Services.GitHTTP.andand.ExternalURL, 'https://git.%s.arvadosapi.com/' end def _clone_url config_var, default_base_fmt - configured_base = Rails.configuration.send config_var - return nil if configured_base == false - prefix = new_record? ? Rails.configuration.uuid_prefix : uuid[0,5] - if prefix == Rails.configuration.uuid_prefix and configured_base != true - base = configured_base + if not config_var + return "" + end + prefix = new_record? ? Rails.configuration.ClusterID : uuid[0,5] + if prefix == Rails.configuration.ClusterID and config_var != URI("") + base = config_var + else + base = URI(default_base_fmt % prefix) + end + if base.path == "" + base.path = "/" + end + if base.scheme == "ssh" + '%s@%s:%s.git' % [base.user, base.host, name] else - base = default_base_fmt % prefix + '%s%s.git' % [base, name] end - '%s%s.git' % [base, name] end end