Commit 1c4187e3 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Treat nil git push revisons as a blank Git SHA value

parent 9bad9b0a
...@@ -9,8 +9,8 @@ module Gitlab ...@@ -9,8 +9,8 @@ module Gitlab
def initialize(project, oldrev, newrev, ref) def initialize(project, oldrev, newrev, ref)
@project = project @project = project
@oldrev = oldrev @oldrev = oldrev.presence || Gitlab::Git::BLANK_SHA
@newrev = newrev @newrev = newrev.presence || Gitlab::Git::BLANK_SHA
@ref = ref @ref = ref
end end
......
...@@ -63,6 +63,12 @@ describe Gitlab::Git::Push do ...@@ -63,6 +63,12 @@ describe Gitlab::Git::Push do
it { is_expected.not_to be_branch_updated } it { is_expected.not_to be_branch_updated }
end end
context 'when oldrev is nil' do
let(:oldrev) { nil }
it { is_expected.not_to be_branch_updated }
end
end end
describe '#force_push?' do describe '#force_push?' do
...@@ -125,4 +131,36 @@ describe Gitlab::Git::Push do ...@@ -125,4 +131,36 @@ describe Gitlab::Git::Push do
end end
end end
end end
describe '#oldrev' do
context 'when a valid oldrev is provided' do
it 'returns oldrev' do
expect(subject.oldrev).to eq oldrev
end
end
context 'when a nil valud is provided' do
let(:oldrev) { nil }
it 'returns blank SHA' do
expect(subject.oldrev).to eq Gitlab::Git::BLANK_SHA
end
end
end
describe '#newrev' do
context 'when valid newrev is provided' do
it 'returns newrev' do
expect(subject.newrev).to eq newrev
end
end
context 'when a nil valud is provided' do
let(:newrev) { nil }
it 'returns blank SHA' do
expect(subject.newrev).to eq Gitlab::Git::BLANK_SHA
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