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:
authorAdam Niedzielski <adamsunday@gmail.com>2016-12-01 14:17:30 +0300
committerAdam Niedzielski <adamsunday@gmail.com>2016-12-01 14:17:30 +0300
commitcb6f8cdfc23a18daf33288c95ae8badec63f53ad (patch)
treecad717c7ba416e3fc7974c833cff154d3a1449a2 /app/models/merge_request_diff.rb
parent2adc6568a6f94b2844c95a0b699a0be9bb8980d1 (diff)
Replace references to MergeRequestDiff#commits with st_commits
when we care only about the number of commits We do not have to instantiate all objects in this case.
Diffstat (limited to 'app/models/merge_request_diff.rb')
-rw-r--r--app/models/merge_request_diff.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index 58a24eb84cb..b8f36a2c958 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -127,11 +127,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
def commits_sha
- if @commits
- commits.map(&:sha)
- else
- st_commits.map { |commit| commit[:id] }
- end
+ st_commits.map { |commit| commit[:id] }
end
def diff_refs
@@ -176,6 +172,10 @@ class MergeRequestDiff < ActiveRecord::Base
CompareService.new.execute(project, head_commit_sha, project, sha, straight: straight)
end
+ def commits_count
+ st_commits.count
+ end
+
private
# Old GitLab implementations may have generated diffs as ["--broken-diff"].