diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2017-08-24 09:20:04 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-24 09:20:04 +0000 |
commit | fb49c94e49149a2043b774ba33daa3fe79febdd4 (patch) | |
tree | e0f1fd8d5b716baec66287116d0b1529cfdca0bb /app | |
parent | 7ab4efa8f8c1c1c0b80684d13bfbb777485f1199 (diff) | |
download | gitlab-ce-fb49c94e49149a2043b774ba33daa3fe79febdd4.tar.gz |
Delegate Repository::branch_exists? and ref_exists? to Gitlab::Git
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index c1e4fcf94a4..cb2cf658084 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -206,12 +206,18 @@ class Repository end def branch_exists?(branch_name) - branch_names.include?(branch_name) + return false unless raw_repository + + @branch_exists_memo ||= Hash.new do |hash, key| + hash[key] = raw_repository.branch_exists?(key) + end + + @branch_exists_memo[branch_name] end def ref_exists?(ref) - rugged.references.exist?(ref) - rescue Rugged::ReferenceError + !!raw_repository&.ref_exists?(ref) + rescue ArgumentError false end @@ -266,6 +272,7 @@ class Repository def expire_branches_cache expire_method_caches(%i(branch_names branch_count)) @local_branches = nil + @branch_exists_memo = nil end def expire_statistics_caches |