Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-04-05 22:10:09 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-04-06 19:23:23 +0300
commit13992ac92e20d74c6b393f71a2775d8c1cd0837c (patch)
treea1863445c568efad7f0be6634bb24e6a71b54eb4 /lib
parente892eeb5460078d127070f51c31bd5fc41a2c876 (diff)
Checksum calculation is handled by Gitaly when feature is enabled
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/checksum.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/gitlab/git/checksum.rb b/lib/gitlab/git/checksum.rb
index 3ef0f0a8854..218651906bf 100644
--- a/lib/gitlab/git/checksum.rb
+++ b/lib/gitlab/git/checksum.rb
@@ -7,13 +7,14 @@ module Gitlab
Failure = Class.new(StandardError)
- attr_reader :path, :relative_path, :storage, :storage_path
+ attr_reader :path, :relative_path, :storage, :storage_path, :gl_repository
- def initialize(storage, relative_path)
+ def initialize(storage, relative_path, gl_repository)
@storage = storage
@storage_path = Gitlab.config.repositories.storages[storage].legacy_disk_path
@relative_path = "#{relative_path}.git"
@path = File.join(storage_path, @relative_path)
+ @gl_repository = gl_repository
end
def calculate
@@ -21,7 +22,13 @@ module Gitlab
failure!(Gitlab::Git::Repository::NoRepository, 'No repository for such path')
end
- calculate_checksum_by_shelling_out
+ raw_repository.gitaly_migrate(:calculate_checksum) do |is_enabled|
+ if is_enabled
+ calculate_checksum_gitaly
+ else
+ calculate_checksum_by_shelling_out
+ end
+ end
end
private
@@ -30,6 +37,10 @@ module Gitlab
raw_repository.exists?
end
+ def calculate_checksum_gitaly
+ gitaly_repository_client.calculate_checksum
+ end
+
def calculate_checksum_by_shelling_out
args = %W(--git-dir=#{path} show-ref --heads --tags)
output, status = run_git(args)
@@ -69,7 +80,11 @@ module Gitlab
end
def raw_repository
- Gitlab::Git::Repository.new(storage, relative_path, nil)
+ @raw_repository ||= Gitlab::Git::Repository.new(storage, relative_path, gl_repository)
+ end
+
+ def gitaly_repository_client
+ raw_repository.gitaly_repository_client
end
def run_git(args)