diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-01-10 01:30:04 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-01-12 17:54:55 +0800 |
commit | 4f00a05152c105814f17a5f582d493435de96747 (patch) | |
tree | 76eab649b7c832afb47ad3e37ead6eb7a4bdaa93 /app/models/repository.rb | |
parent | 3fde958f36fa9c3bfa30ed1f73108e0640722926 (diff) | |
download | gitlab-ce-4f00a05152c105814f17a5f582d493435de96747.tar.gz |
Introduce PredicateMemoization cop and fix offenses
with StrongMemoize
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index d27212b2058..8e9f33c174c 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -895,15 +895,18 @@ class Repository branch = Gitlab::Git::Branch.find(self, branch_or_name) if branch - @root_ref_sha ||= commit(root_ref).sha - same_head = branch.target == @root_ref_sha - merged = ancestor?(branch.target, @root_ref_sha) + same_head = branch.target == root_ref_sha + merged = ancestor?(branch.target, root_ref_sha) !same_head && merged else nil end end + def root_ref_sha + @root_ref_sha ||= commit(root_ref).sha + end + delegate :merged_branch_names, to: :raw_repository def merge_base(first_commit_id, second_commit_id) |