Don't use DiffCollection for deltas
This commit is contained in:
parent
62b0eb2c0b
commit
48254d187f
5 changed files with 14 additions and 6 deletions
|
@ -373,7 +373,7 @@ class Commit
|
||||||
def repo_changes
|
def repo_changes
|
||||||
changes = { added: [], modified: [], removed: [] }
|
changes = { added: [], modified: [], removed: [] }
|
||||||
|
|
||||||
raw_diffs(deltas_only: true).each do |diff|
|
raw_deltas.each do |diff|
|
||||||
if diff.deleted_file
|
if diff.deleted_file
|
||||||
changes[:removed] << diff.old_path
|
changes[:removed] << diff.old_path
|
||||||
elsif diff.renamed_file || diff.new_file
|
elsif diff.renamed_file || diff.new_file
|
||||||
|
@ -386,6 +386,10 @@ class Commit
|
||||||
changes
|
changes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def raw_deltas
|
||||||
|
raw.deltas
|
||||||
|
end
|
||||||
|
|
||||||
def merged_merge_request?(user)
|
def merged_merge_request?(user)
|
||||||
!!merged_merge_request(user)
|
!!merged_merge_request(user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,7 +67,7 @@ class GitPushService < BaseService
|
||||||
paths = Set.new
|
paths = Set.new
|
||||||
|
|
||||||
@push_commits.each do |commit|
|
@push_commits.each do |commit|
|
||||||
commit.raw_diffs(deltas_only: true).each do |diff|
|
commit.raw_deltas.each do |diff|
|
||||||
paths << diff.new_path
|
paths << diff.new_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -142,10 +142,10 @@ class IrkerWorker
|
||||||
end
|
end
|
||||||
|
|
||||||
def files_count(commit)
|
def files_count(commit)
|
||||||
diffs = commit.raw_diffs(deltas_only: true)
|
diff_size = commit.raw_deltas.size
|
||||||
|
|
||||||
files = "#{diffs.real_size} file"
|
files = "#{diff_size} file"
|
||||||
files += 's' if diffs.size > 1
|
files += 's' if diff_size > 1
|
||||||
files
|
files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,10 @@ module Gitlab
|
||||||
Commit.diff_from_parent(raw_commit, options)
|
Commit.diff_from_parent(raw_commit, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deltas
|
||||||
|
@deltas ||= diff_from_parent.each_delta.map { |d| Gitlab::Git::Diff.new(d) }
|
||||||
|
end
|
||||||
|
|
||||||
def has_zero_stats?
|
def has_zero_stats?
|
||||||
stats.total.zero?
|
stats.total.zero?
|
||||||
rescue
|
rescue
|
||||||
|
|
|
@ -584,7 +584,7 @@ describe GitPushService, services: true do
|
||||||
commit = double(:commit)
|
commit = double(:commit)
|
||||||
diff = double(:diff, new_path: 'README.md')
|
diff = double(:diff, new_path: 'README.md')
|
||||||
|
|
||||||
expect(commit).to receive(:raw_diffs).with(deltas_only: true).
|
expect(commit).to receive(:raw_deltas).
|
||||||
and_return([diff])
|
and_return([diff])
|
||||||
|
|
||||||
service.push_commits = [commit]
|
service.push_commits = [commit]
|
||||||
|
|
Loading…
Reference in a new issue