We could simply count the commits
This commit is contained in:
parent
17c53d7d0d
commit
4925ec5087
|
@ -899,7 +899,8 @@ class MergeRequest < ActiveRecord::Base
|
||||||
def compute_diverged_commits_count
|
def compute_diverged_commits_count
|
||||||
return 0 unless source_branch_sha && target_branch_sha
|
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
|
end
|
||||||
private :compute_diverged_commits_count
|
private :compute_diverged_commits_count
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Improve the performance for counting commits
|
||||||
|
merge_request: 15628
|
||||||
|
author:
|
||||||
|
type: performance
|
|
@ -505,7 +505,7 @@ module Gitlab
|
||||||
|
|
||||||
# Counts the amount of commits between `from` and `to`.
|
# Counts the amount of commits between `from` and `to`.
|
||||||
def count_commits_between(from, to)
|
def count_commits_between(from, to)
|
||||||
Commit.between(self, from, to).size
|
count_commits(ref: "#{from}..#{to}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the SHA of the most recent common ancestor of +from+ and +to+
|
# Returns the SHA of the most recent common ancestor of +from+ and +to+
|
||||||
|
|
Loading…
Reference in New Issue