diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-02 13:17:51 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-02 13:17:51 +0000 |
commit | 780dcf9cdb9a86b83388f34b07485382bf047cfd (patch) | |
tree | a3a15a89476dec9669900e0b36b26dd302a53272 /lib/gitlab/git | |
parent | 554c4e0d6fda653667c4c7e8f4b2088837636000 (diff) | |
parent | 573d0989110ccb0630481f416d1a4f8fd05ee608 (diff) | |
download | gitlab-ce-780dcf9cdb9a86b83388f34b07485382bf047cfd.tar.gz |
Merge branch 'gitaly-branch-tag-count' into 'master'
Use Gitaly for getting Branch/Tag counts
Closes gitaly#157
See merge request !10780
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/repository.rb | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 18eda0279f7..c3f0de76d01 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 |