diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-04 16:30:33 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-04 19:42:40 +0100 |
commit | b263ab618c59ff9e377780c6120ab60fd97aefd0 (patch) | |
tree | d8e00c2ad6a6fc94deca03c1f88f42b65a261d41 /app/models | |
parent | 312d3faf6f71e4dc7fc2870ea823115475f14c8b (diff) | |
download | gitlab-ce-b263ab618c59ff9e377780c6120ab60fd97aefd0.tar.gz |
Dedicated method for counting commits between refsimprove-diverging-commit-counts
gitlab_git 8.1 adds the ability to count the amount of commits between
two references without having to allocate anything but regular
Rugged::Commit objects. This in turn speeds up the process of counting
the number of commits a branch is ahead/behind by about 3.5x.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/repository.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 130daddd9d1..e813c946bc1 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -184,8 +184,11 @@ class Repository 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 = commits_between(branch.target, root_ref_hash).size - number_commits_ahead = commits_between(root_ref_hash, branch.target).size + number_commits_behind = raw_repository. + count_commits_between(branch.target, root_ref_hash) + + number_commits_ahead = raw_repository. + count_commits_between(root_ref_hash, branch.target) { behind: number_commits_behind, ahead: number_commits_ahead } end |