class RepositoriesController < ApplicationController
before_filter :set_share_links, if: -> { defined? @object }
+ if Repository.disable_repository_browsing?
+ before_filter :render_browsing_disabled, only: [:show_tree, :show_blob, :show_commit]
+ end
def index_pane_list
%w(recent help)
def show_commit
@commit = params[:commit]
end
+
+ protected
+
+ def render_browsing_disabled
+ render_not_found ActionController::RoutingError.new("Repository browsing features disabled")
+ end
end
subtree
end
+ # git 2.1.4 does not use credential helpers reliably, see #5416
+ def self.disable_repository_browsing?
+ return false if Rails.configuration.use_git2_despite_bug_risk
+ if @buggy_git_version.nil?
+ @buggy_git_version = /git version 2/ =~ `git version`
+ end
+ @buggy_git_version
+ end
+
protected
# refresh fetches the latest repository content into the local
<% # link to repo tree/file only if the repo is readable
# and the commit is a sha1...
repo =
- (/^[0-9a-f]{40}$/ =~ current_component[:script_version] and
+ (not Repository.disable_repository_browsing? and
+ /^[0-9a-f]{40}$/ =~ current_component[:script_version] and
Repository.where(name: current_component[:repository]).first)
# ...and the api server provides an http:// or https:// url
# Enable response payload compression in Arvados API requests.
include_accept_encoding_header_in_api_requests: true
+
+ # Enable repository browsing even if git2 is installed. Repository
+ # browsing requires credential helpers, which do not work reliably
+ # as of git version 2.1.4. If you have git version 2.* and you want
+ # to use it anyway, change this to true.
+ use_git2_despite_bug_risk: false
[:active, :spectator].each do |user|
test "show tree to #{user}" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
reset_api_fixtures_after_test false
sha1, _, _ = stub_repo_content
get :show_tree, {
end
test "show commit to #{user}" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
reset_api_fixtures_after_test false
sha1, commit, _ = stub_repo_content
get :show_commit, {
end
test "show blob to #{user}" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
reset_api_fixtures_after_test false
sha1, _, filedata = stub_repo_content filename: 'COPYING'
get :show_blob, {
['', '/'].each do |path|
test "show tree with path '#{path}'" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
reset_api_fixtures_after_test false
sha1, _, _ = stub_repo_content filename: 'COPYING'
get :show_tree, {
end
test "browse repository from jobs#show" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
sha1 = api_fixture('jobs')['running']['script_version']
_, fakecommit, fakefile =
stub_repo_content sha1: sha1, filename: 'crunch_scripts/hash'
end
test "browse using arv-git-http" do
+ skip "git2 is unreliable" if Repository.disable_repository_browsing?
repo = api_fixture('repositories')['foo']
portfile =
File.expand_path('../../../../../tmp/arv-git-httpd-ssl.port', __FILE__)