Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin (godfat) <godfat@godfat.org>2018-01-05 19:52:06 +0300
committerRémy Coutable <remy@rymai.me>2018-01-05 19:52:06 +0300
commit33c5630b02a783a749cc0bf63474f643652cdeeb (patch)
tree0d30ab08be0f71e4317822f7a5a2dd13a5ad4fd7 /app/models
parentb72af2b9c78527ea988bc6a69c62ec95645a6c48 (diff)
Use --left-right and --max-count for counting diverging commits
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb12
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