diff options
author | Rémy Coutable <remy@rymai.me> | 2017-04-05 09:30:20 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-10 16:10:18 +0200 |
commit | cb20cfa244db896b87d2fb8b6ccad5b9f0713298 (patch) | |
tree | 3aedf108aff72587bb6e70206dfe0adade3a0783 /lib | |
parent | 710cd82cc16a9c67458c72ea6b2c4b676234ef79 (diff) | |
download | gitlab-ce-cb20cfa244db896b87d2fb8b6ccad5b9f0713298.tar.gz |
Retrieve Git-specific env in Gitlab::Git::Repository#rugged
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/repository.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index fc473b2c21e..41ab73abb56 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -8,6 +8,10 @@ module Gitlab class Repository include Gitlab::Git::Popen + ALLOWED_OBJECT_DIRECTORIES_VARIABLES = %w[ + GIT_OBJECT_DIRECTORY + GIT_ALTERNATE_OBJECT_DIRECTORIES + ].freeze SEARCH_CONTEXT_LINES = 3 NoRepository = Class.new(StandardError) @@ -58,7 +62,7 @@ module Gitlab end def rugged - @rugged ||= Rugged::Repository.new(path) + @rugged ||= Rugged::Repository.new(path, alternates: alternate_object_directories) rescue Rugged::RepositoryError, Rugged::OSError raise NoRepository.new('no repository for such path') end @@ -978,6 +982,10 @@ module Gitlab private + def alternate_object_directories + Gitlab::Git::Env.all.values_at(*ALLOWED_OBJECT_DIRECTORIES_VARIABLES).compact + end + # Get the content of a blob for a given commit. If the blob is a commit # (for submodules) then return the blob's OID. def blob_content(commit, blob_name) |