summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-11-28 21:43:31 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-11-28 21:45:34 +0800
commit33caad43802eb9fa807231ee38a1ddf2418e65ea (patch)
tree170e8b906ea7c4e7c29c23bb45f289cb5705326d
parent0185d7800b23daecd44abe8e9a0b2672a831e8be (diff)
downloadgitlab-ce-use-count_commits-directly.tar.gz
We could simply count the commitsuse-count_commits-directly
-rw-r--r--app/models/merge_request.rb3
-rw-r--r--lib/gitlab/git/repository.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index e4d8f486c77..7c69617a49f 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -887,7 +887,8 @@ class MergeRequest < ActiveRecord::Base
def compute_diverged_commits_count
return 0 unless source_branch_sha && target_branch_sha
- Gitlab::Git::Commit.between(target_project.repository.raw_repository, source_branch_sha, target_branch_sha).size
+ target_project.repository
+ .count_commits_between(source_branch_sha, target_branch_sha)
end
private :compute_diverged_commits_count
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index a6e7c410bdd..563f56ac549 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -505,7 +505,7 @@ module Gitlab
# Counts the amount of commits between `from` and `to`.
def count_commits_between(from, to)
- Commit.between(self, from, to).size
+ count_commits(ref: "#{from}..#{to}")
end
# Returns the SHA of the most recent common ancestor of +from+ and +to+