diff options
author | Lin Jen-Shin (godfat) <godfat@godfat.org> | 2018-01-05 16:52:06 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-05 16:52:06 +0000 |
commit | 33c5630b02a783a749cc0bf63474f643652cdeeb (patch) | |
tree | 0d30ab08be0f71e4317822f7a5a2dd13a5ad4fd7 /app/models/repository.rb | |
parent | b72af2b9c78527ea988bc6a69c62ec95645a6c48 (diff) | |
download | gitlab-ce-33c5630b02a783a749cc0bf63474f643652cdeeb.tar.gz |
Use --left-right and --max-count for counting diverging commits
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 4bedcbfb6a2..7b8f5794a87 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -4,6 +4,7 @@ class Repository REF_MERGE_REQUEST = 'merge-requests'.freeze REF_KEEP_AROUND = 'keep-around'.freeze REF_ENVIRONMENTS = 'environments'.freeze + MAX_DIVERGING_COUNT = 1000 RESERVED_REFS_NAMES = %W[ heads @@ -278,11 +279,12 @@ 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 = raw_repository - .count_commits_between(branch.dereferenced_target.sha, root_ref_hash) - - number_commits_ahead = raw_repository - .count_commits_between(root_ref_hash, branch.dereferenced_target.sha) + number_commits_behind, number_commits_ahead = + raw_repository.count_commits_between( + root_ref_hash, + branch.dereferenced_target.sha, + left_right: true, + max_count: MAX_DIVERGING_COUNT) { behind: number_commits_behind, ahead: number_commits_ahead } end |