Merge branch 'sh-optimize-commit-stats' into 'master'

Speed up generation of commit stats by using Rugged native methods

See merge request gitlab-org/gitlab-ce!16186
This commit is contained in:
Robert Speicher 2018-01-03 17:39:24 +00:00
commit 946a3634bc
3 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
title: Speed up generation of commit stats by using Rugged native methods
merge_request:
author:
type: performance

View File

@ -34,13 +34,8 @@ module Gitlab
def rugged_stats(commit)
diff = commit.rugged_diff_from_parent
diff.each_patch do |p|
# TODO: Use the new Rugged convenience methods when they're released
@additions += p.stat[0]
@deletions += p.stat[1]
@total += p.changes
end
_files_changed, @additions, @deletions = diff.stat
@total = @additions + @deletions
end
end
end

View File

@ -428,6 +428,11 @@ describe Gitlab::Git::Commit, seed_helper: true do
subject { super().deletions }
it { is_expected.to eq(6) }
end
describe '#total' do
subject { super().total }
it { is_expected.to eq(17) }
end
end
describe '#stats with gitaly on' do