diff options
author | John Cai <jcai@gitlab.com> | 2019-01-10 05:45:47 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-02-07 09:25:37 +0300 |
commit | 1f2f38f59a719f7dae110835b8beb3d94fdcd94d (patch) | |
tree | 3ced63bee26527bb69e570b65ec568e8c1e35a71 /app | |
parent | 3daa53e821c68069d68627bebd58a8291269106d (diff) |
Add client support for count diverging commits
Adds the client call for the gitaly rpc CountDivergingCommits
fixing signature
simplifying commit logic
adding test for max-count
refactoring tests
Diffstat (limited to 'app')
-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 7c50b4488e5..ed55a6e572b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -288,13 +288,16 @@ class Repository # 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( + raw_repository.diverging_commit_count( @root_ref_hash, branch.dereferenced_target.sha, - left_right: true, max_count: MAX_DIVERGING_COUNT) - { behind: number_commits_behind, ahead: number_commits_ahead } + if number_commits_behind + number_commits_ahead >= MAX_DIVERGING_COUNT + { distance: MAX_DIVERGING_COUNT } + else + { behind: number_commits_behind, ahead: number_commits_ahead } + end end end |