Skip to content
Snippets Groups Projects
Commit 4925ec50 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

We could simply count the commits

parent 17c53d7d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -899,7 +899,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
 
Loading
Loading
---
title: Improve the performance for counting commits
merge_request: 15628
author:
type: performance
Loading
Loading
@@ -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+
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment