Commit 5de62109 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'deltas-only-ee' into 'master'

Use new Commit#raw_deltas method

See merge request !1854
parents 32cb7d63 886d26ef
......@@ -335,6 +335,8 @@ class Commit
# end
end
delegate :deltas, to: :raw, prefix: :raw
def diffs(diff_options = nil)
Gitlab::Diff::FileCollection::Commit.new(self, diff_options: diff_options)
end
......@@ -372,7 +374,7 @@ class Commit
def repo_changes
changes = { added: [], modified: [], removed: [] }
raw_diffs(deltas_only: true).each do |diff|
raw_deltas.each do |diff|
if diff.deleted_file
changes[:removed] << diff.old_path
elsif diff.renamed_file || diff.new_file
......
......@@ -72,7 +72,7 @@ class GitPushService < BaseService
paths = Set.new
@push_commits.each do |commit|
commit.raw_diffs(deltas_only: true).each do |diff|
commit.raw_deltas.each do |diff|
paths << diff.new_path
end
end
......
......@@ -142,10 +142,10 @@ class IrkerWorker
end
def files_count(commit)
diffs = commit.raw_diffs(deltas_only: true)
diff_size = commit.raw_deltas.size
files = "#{diffs.real_size} file"
files += 's' if diffs.size > 1
files = "#{diff_size} file"
files += 's' if diff_size > 1
files
end
......
......@@ -188,7 +188,7 @@ module Gitlab
return if validations.empty?
commit.raw_diffs(deltas_only: true).each do |diff|
commit.raw_deltas.each do |diff|
validations.each do |validation|
if error = validation.call(diff)
return error
......
......@@ -192,6 +192,10 @@ module Gitlab
Commit.diff_from_parent(raw_commit, options)
end
def deltas
@deltas ||= diff_from_parent.each_delta.map { |d| Gitlab::Git::Diff.new(d) }
end
def has_zero_stats?
stats.total.zero?
rescue
......
......@@ -623,7 +623,7 @@ describe GitPushService, services: true do
commit = double(:commit)
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])
service.push_commits = [commit]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment