Merge branch '18947-githttpd'
[arvados.git] / apps / workbench / app / models / repository.rb
index 1caab89cc70fe643dc37965fcde5561ce0096f70..fd30be946206db3c000460d85fa18e3c4a8f9fec 100644 (file)
@@ -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' }
@@ -72,12 +76,12 @@ 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
+          system(*cmd, in: "/dev/null")
           raise GitCommandError.new($?.to_s) unless $?.exitstatus == 0
         end
       end
@@ -90,16 +94,17 @@ class Repository < ArvadosBase
       '!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
+      system(*cmd, in: "/dev/null")
       raise GitCommandError.new($?.to_s) unless $?.exitstatus == 0
     end
     env = {}.
       merge(ENV).
-      merge('ARVADOS_API_TOKEN' => Thread.current[:arvados_api_token])
+      merge('ARVADOS_API_TOKEN' => Thread.current[:arvados_api_token],
+            'GIT_TERMINAL_PROMPT' => '0')
     cmd = ['git', '--git-dir', @workdir] + gitcmd
-    io = IO.popen(env, cmd, err: [:child, :out])
+    io = IO.popen(env, cmd, err: [:child, :out], in: "/dev/null")
     output = io.read
     io.close
     # "If [io] is opened by IO.popen, close sets $?." --ruby 2.2.1 docs