X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e24125041ad492b45c97feffb33a037c5adda734..3aaefcb3c76ff470b475d950398d01255e87712a:/apps/workbench/app/models/repository.rb diff --git a/apps/workbench/app/models/repository.rb b/apps/workbench/app/models/repository.rb index aa7791388f..8b89d57ee9 100644 --- a/apps/workbench/app/models/repository.rb +++ b/apps/workbench/app/models/repository.rb @@ -1,6 +1,10 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class Repository < ArvadosBase def self.creatable? - current_user and current_user.is_admin + false end def attributes_for_display super.reject { |x| x[0] == 'fetch_url' } @@ -48,6 +52,12 @@ class Repository < ArvadosBase subtree end + # http_fetch_url returns the first http:// or https:// url (if any) + # in the api response's clone_urls attribute. + def http_fetch_url + clone_urls.andand.select { |u| /^http/ =~ u }.first + end + protected # refresh fetches the latest repository content into the local @@ -59,12 +69,6 @@ class Repository < ArvadosBase @fresh = true end - # http_fetch_url returns the first http:// or https:// url (if any) - # in the api response's clone_urls attribute. - def http_fetch_url - clone_urls.andand.select { |u| /^http/ =~ u }.first - end - # run_git sets up the ARVADOS_API_TOKEN environment variable, # creates a local git directory for this repository if necessary, # executes "git --git-dir localgitdir {args to run_git}", and @@ -72,9 +76,9 @@ class Repository < ArvadosBase # non-zero. def run_git *gitcmd if not @workdir - workdir = File.expand_path uuid+'.git', Rails.configuration.repository_cache + workdir = File.expand_path uuid+'.git', Rails.configuration.Workbench.RepositoryCache if not File.exists? workdir - FileUtils.mkdir_p Rails.configuration.repository_cache + FileUtils.mkdir_p Rails.configuration.Workbench.RepositoryCache [['git', 'init', '--bare', workdir], ].each do |cmd| system *cmd @@ -87,10 +91,10 @@ class Repository < ArvadosBase "credential.#{http_fetch_url}.username", 'none'], ['git', '--git-dir', @workdir, 'config', '--local', "credential.#{http_fetch_url}.helper", - '!token(){ echo password="$ARVADOS_API_TOKEN"; }; token'], + '!cred(){ cat >/dev/null; if [ "$1" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred'], ['git', '--git-dir', @workdir, 'config', '--local', 'http.sslVerify', - Rails.configuration.arvados_insecure_https ? 'false' : 'true'], + Rails.configuration.TLS.Insecure ? 'false' : 'true'], ].each do |cmd| system *cmd raise GitCommandError.new($?.to_s) unless $?.exitstatus == 0