BigW Consortium Gitlab

Commit 2e8ec7e7 by Jeff Stubler

Fix diverging commit count calculation

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.
parent 932a7fd9
...@@ -157,9 +157,12 @@ class Repository ...@@ -157,9 +157,12 @@ class Repository
end end
def diverging_commit_counts(branch) def diverging_commit_counts(branch)
root_ref_hash = raw_repository.rev_parse_target(root_ref).oid
cache.fetch(:"diverging_commit_counts_#{branch.name}") do cache.fetch(:"diverging_commit_counts_#{branch.name}") do
number_commits_behind = commits_between(branch.name, root_ref).size # Rugged seems to throw a `ReferenceError` when given branch_names rather
number_commits_ahead = commits_between(root_ref, branch.name).size # 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 } { behind: number_commits_behind, ahead: number_commits_ahead }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment