Commit 5f2698ac authored by Thong Kuah's avatar Thong Kuah

Merge branch '13495-x-fix-sha-equality-semantics' into 'master'

Allow shas that are nil to compare to nil shas

See merge request gitlab-org/gitlab!21991
parents 0af875d5 d0a04466
......@@ -88,6 +88,7 @@ module Gitlab
end
def shas_eql?(sha1, sha2)
return true if sha1.nil? && sha2.nil?
return false if sha1.nil? || sha2.nil?
return false unless sha1.class == sha2.class
......
......@@ -73,7 +73,8 @@ describe Gitlab::Git do
[sha, short_sha, true],
[sha, sha.reverse, false],
[sha, too_short_sha, false],
[sha, nil, false]
[sha, nil, false],
[nil, nil, true]
]
end
......
......@@ -63,6 +63,20 @@ describe Commit do
end
end
describe '#diff_refs' do
it 'is equal to itself' do
expect(commit.diff_refs).to eq(commit.diff_refs)
end
context 'from a factory' do
let(:commit) { create(:commit) }
it 'is equal to itself' do
expect(commit.diff_refs).to eq(commit.diff_refs)
end
end
end
describe '#author', :request_store do
it 'looks up the author in a case-insensitive way' do
user = create(:user, email: commit.author_email.upcase)
......
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