diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-04-19 11:06:20 +0200 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-04-28 13:07:53 +0200 |
commit | 6f89bd3628322d0c17f97163d060e6ef7238de3c (patch) | |
tree | 8618f7160c14bca46438f46464d5da671d118945 /lib/gitlab | |
parent | ef518df28adc1366d868cb990952e87f60e8b0eb (diff) | |
download | gitlab-ce-6f89bd3628322d0c17f97163d060e6ef7238de3c.tar.gz |
Use Gitaly for getting Branch/Tag counts
- Backup-rake-spec fixed. Storage config broken
- Use rugged to compare branch/tag-count in specs
- upgrade gitaly
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/git/repository.rb | 29 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/ref.rb | 8 |
2 files changed, 31 insertions, 6 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 452dba7971d..4af7f1396c7 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -122,13 +122,30 @@ module Gitlab # Returns the number of valid branches def branch_count - rugged.branches.count do |ref| - begin - ref.name && ref.target # ensures the branch is valid + Gitlab::GitalyClient.migrate(:branch_names) do |is_enabled| + if is_enabled + gitaly_ref_client.count_branch_names + else + rugged.branches.count do |ref| + begin + ref.name && ref.target # ensures the branch is valid - true - rescue Rugged::ReferenceError - false + true + rescue Rugged::ReferenceError + false + end + end + end + end + end + + # Returns the number of valid tags + def tag_count + Gitlab::GitalyClient.migrate(:tag_names) do |is_enabled| + if is_enabled + gitaly_ref_client.count_tag_names + else + rugged.tags.count end end end diff --git a/lib/gitlab/gitaly_client/ref.rb b/lib/gitlab/gitaly_client/ref.rb index d3c0743db4e..2a5e8f73e55 100644 --- a/lib/gitlab/gitaly_client/ref.rb +++ b/lib/gitlab/gitaly_client/ref.rb @@ -34,6 +34,14 @@ module Gitlab stub.find_ref_name(request).name end + def count_tag_names + tag_names.count + end + + def count_branch_names + branch_names.count + end + private def consume_refs_response(response, prefix:) |