diff options
author | Jeff Stubler <brunsa2@gmail.com> | 2015-12-15 16:23:52 -0600 |
---|---|---|
committer | Jeff Stubler <brunsa2@gmail.com> | 2015-12-15 16:23:52 -0600 |
commit | 2e8ec7e7204b2876218db34439584204b1062265 (patch) | |
tree | 57160b3fbdd7a02b72cadfd9067e6d61050fdb7a | |
parent | 932a7fd96f5977db6119205daa85495ea161dd68 (diff) | |
download | gitlab-ce-2e8ec7e7204b2876218db34439584204b1062265.tar.gz |
Fix diverging commit count calculationbrunsa2/gitlab-ce-diverging-branch-graphs
Rugged seemed to stop accepting branch names as valid refs, throwing `Rugged::ReferenceError` exceptions. Now the branch target rather than branch name is used, and the default branch's hash is also calculated, and these work properly.
This used to work and might be something worth re-investigating in the future.
-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 4186ef295c9..77e5bd975ec 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -157,9 +157,12 @@ class Repository end def diverging_commit_counts(branch) + root_ref_hash = raw_repository.rev_parse_target(root_ref).oid cache.fetch(:"diverging_commit_counts_#{branch.name}") do - number_commits_behind = commits_between(branch.name, root_ref).size - number_commits_ahead = commits_between(root_ref, branch.name).size + # 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 { behind: number_commits_behind, ahead: number_commits_ahead } end |