Merge branch 'master' into 10081-cwl-run-same-job
[arvados.git] / apps / workbench / app / models / repository.rb
index 48c7f9efcbc34a3402d0f57ea1ab2ecebf7691e1..7f9513a5a9c9e6e0010085329dfe4c7afaf77d1d 100644 (file)
@@ -1,6 +1,6 @@
 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 +48,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,14 +65,6 @@ class Repository < ArvadosBase
     @fresh = true
   end
 
-  # http_fetch_url returns an http:// or https:// fetch-url which can
-  # accept arvados API token authentication. The API server currently
-  # advertises SSH fetch-urls, which work for users with SSH keys but
-  # are useless for fetching repository content into workbench itself.
-  def http_fetch_url
-    "https://git.#{uuid[0,5]}.arvadosapi.com/#{name}.git"
-  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
@@ -89,7 +87,7 @@ 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'],