Compare ids of commits if present for equality test

This solves a problem where commits populated with Gitaly were not equal
to commits populated with Rugged. This is because Gitaly may not return
all fields of a commit for optimizations purposes, which resulted in
false negatives when comparing the same commit (commits with the same
sha) with different sources.
This commit is contained in:
Alejandro Rodríguez 2017-05-09 15:41:21 -03:00
parent f3cbb0a450
commit 71569a9c41
1 changed files with 1 additions and 7 deletions

View File

@ -19,13 +19,7 @@ module Gitlab
def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit)
methods = [:message, :parent_ids, :authored_date, :author_name,
:author_email, :committed_date, :committer_name,
:committer_email]
methods.all? do |method|
send(method) == other.send(method)
end
id && id == other.id
end
class << self