Commit a1ce6618 authored by Stan Hu's avatar Stan Hu

Fix EE delta size check handling with annotated tags

Pushes with annotated tags would fail when the repository
size limits were enabled.

Closes #3589
parent c49ad301
---
title: Fix EE delta size check handling with annotated tags
merge_request:
author:
type: fixed
...@@ -7,6 +7,9 @@ module EE ...@@ -7,6 +7,9 @@ module EE
begin begin
tree_a = repo.lookup(change[:oldrev]) tree_a = repo.lookup(change[:oldrev])
tree_b = repo.lookup(change[:newrev]) tree_b = repo.lookup(change[:newrev])
return size_of_deltas unless diffable?(tree_a) && diffable?(tree_b)
diff = tree_a.diff(tree_b) diff = tree_a.diff(tree_b)
diff.each_delta do |d| diff.each_delta do |d|
...@@ -25,6 +28,10 @@ module EE ...@@ -25,6 +28,10 @@ module EE
size_of_deltas size_of_deltas
end end
end end
def self.diffable?(object)
[Rugged::Commit, Rugged::Tree].include?(object.class)
end
end end
end end
end end
...@@ -12,5 +12,19 @@ describe EE::Gitlab::Deltas do ...@@ -12,5 +12,19 @@ describe EE::Gitlab::Deltas do
expect(described_class.delta_size_check(change, project.repository)).to be > 0 expect(described_class.delta_size_check(change, project.repository)).to be > 0
end end
it 'handles annotated tags on an object' do
object_id = 'faaf198af3a36dbf41961466703cc1d47c61d051'
options = { message: 'test tag message\n',
tagger: { name: 'John Smith', email: 'john@gmail.com' } }
result = project.repository.rugged.tags.create('annotated-tag', object_id, options)
change = {
oldrev: result.annotation.oid,
newrev: TestEnv::BRANCH_SHA['master']
}
expect(described_class.delta_size_check(change, project.repository)).to eq(0)
end
end end
end end
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