Treat nil git push revisons as a blank Git SHA value

This commit is contained in:
Grzegorz Bizon 2018-10-02 13:01:55 +02:00
parent 9bad9b0a68
commit 1c4187e38e
2 changed files with 40 additions and 2 deletions

View File

@ -9,8 +9,8 @@ module Gitlab
def initialize(project, oldrev, newrev, ref)
@project = project
@oldrev = oldrev
@newrev = newrev
@oldrev = oldrev.presence || Gitlab::Git::BLANK_SHA
@newrev = newrev.presence || Gitlab::Git::BLANK_SHA
@ref = ref
end

View File

@ -63,6 +63,12 @@ describe Gitlab::Git::Push do
it { is_expected.not_to be_branch_updated }
end
context 'when oldrev is nil' do
let(:oldrev) { nil }
it { is_expected.not_to be_branch_updated }
end
end
describe '#force_push?' do
@ -125,4 +131,36 @@ describe Gitlab::Git::Push do
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