diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-03-26 18:57:13 +0300 |
---|---|---|
committer | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-03-28 17:06:17 +0300 |
commit | 05b4b2d9679ccd09cf9723207603d0d3f670df30 (patch) | |
tree | 6f7e7629cb4069f2ba977f7826e03c7c57fd4239 /app/models/repository.rb | |
parent | a1cde68d208437a470267e28ccff66fe8be88c2e (diff) |
Reuse root_ref_hash for performance on Branches
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 42f1ac43e29..904bfe06ce6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -253,13 +253,13 @@ class Repository end def diverging_commit_counts(branch) - root_ref_hash = raw_repository.commit(root_ref).id + @root_ref_hash ||= raw_repository.commit(root_ref).id cache.fetch(:"diverging_commit_counts_#{branch.name}") do # Rugged seems to throw a `ReferenceError` when given branch_names rather # than SHA-1 hashes number_commits_behind, number_commits_ahead = raw_repository.count_commits_between( - root_ref_hash, + @root_ref_hash, branch.dereferenced_target.sha, left_right: true, max_count: MAX_DIVERGING_COUNT) |