diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-09 15:38:38 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-09 15:38:38 +0000 |
commit | c1174901c67f76a10f5a07ce3990af00ca1e0b05 (patch) | |
tree | 165476525fdb91309c2634505493766a836adffe | |
parent | 5354c29352416a606f16c58e65bfbafebfa1ef3c (diff) | |
parent | 3107f2e460d8db35f7ddd0cc5f68575233bfc133 (diff) | |
download | gitlab-ce-c1174901c67f76a10f5a07ce3990af00ca1e0b05.tar.gz |
Merge branch 'deltas-only' into 'master'
Don't use DiffCollection for deltas
See merge request !11201
-rw-r--r-- | app/models/commit.rb | 4 | ||||
-rw-r--r-- | app/services/git_push_service.rb | 2 | ||||
-rw-r--r-- | app/workers/irker_worker.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/git/commit.rb | 4 | ||||
-rw-r--r-- | spec/services/git_push_service_spec.rb | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 9359b323ed4..dea18bfedef 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -336,6 +336,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 @@ -373,7 +375,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 diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index b8bd7720265..d22236b961b 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -67,7 +67,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 diff --git a/app/workers/irker_worker.rb b/app/workers/irker_worker.rb index c9658b3fe17..22f67fa9e9f 100644 --- a/app/workers/irker_worker.rb +++ b/app/workers/irker_worker.rb @@ -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 diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 3a73697dc5d..f9a9b767ef4 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -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 diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 8c2415b4e07..ab06f45dbb9 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -584,7 +584,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] |