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
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-08-02 21:59:44 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-08-07 19:53:32 +0300
commitc4f55ce32d6160b43c518954219cca69077b5001 (patch)
tree63307e0f6bb2bddbaf079f9414ca4f2cd9d67d1c /lib/gitlab/git
parentb12107a0b953b566cd58db30ae880800a4a695a6 (diff)
Migrate Gitlab::Git::Repository#size to Gitaly
Closes gitaly#437
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/repository.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 1005a819f95..ea01bec2d5a 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -282,7 +282,14 @@ module Gitlab
# Return repo size in megabytes
def size
- size = popen(%w(du -sk), path).first.strip.to_i
+ size = gitaly_migrate(:repository_size) do |is_enabled|
+ if is_enabled
+ size_by_gitaly
+ else
+ size_by_shelling_out
+ end
+ end
+
(size.to_f / 1024).round(2)
end
@@ -942,6 +949,14 @@ module Gitlab
gitaly_ref_client.tags
end
+ def size_by_shelling_out
+ popen(%w(du -sk), path).first.strip.to_i
+ end
+
+ def size_by_gitaly
+ gitaly_repository_client.repository_size
+ end
+
def count_commits_by_gitaly(options)
gitaly_commit_client.commit_count(options[:ref], options)
end