Commit 4b7e9eaa authored by Douwe Maan's avatar Douwe Maan

Treat Repository instances with the same disk path as the same hash key

parent 5f0e4040
...@@ -69,7 +69,13 @@ class Repository ...@@ -69,7 +69,13 @@ class Repository
end end
def ==(other) def ==(other)
@disk_path == other.disk_path other.is_a?(self.class) && @disk_path == other.disk_path
end
alias_method :eql?, :==
def hash
[self.class, @disk_path].hash
end end
def raw_repository def raw_repository
......
...@@ -23,7 +23,7 @@ module Gitlab ...@@ -23,7 +23,7 @@ module Gitlab
alias_method :eql?, :== alias_method :eql?, :==
def hash def hash
[base_sha, start_sha, head_sha].hash [self.class, base_sha, start_sha, head_sha].hash
end end
# There is only one case in which we will have `start_sha` and `head_sha`, # There is only one case in which we will have `start_sha` and `head_sha`,
......
...@@ -80,7 +80,13 @@ module Gitlab ...@@ -80,7 +80,13 @@ module Gitlab
end end
def ==(other) def ==(other)
[storage, relative_path] == [other.storage, other.relative_path] other.is_a?(self.class) && [storage, relative_path] == [other.storage, other.relative_path]
end
alias_method :eql?, :==
def hash
[self.class, storage, relative_path].hash
end end
# This method will be removed when Gitaly reaches v1.1. # This method will be removed when Gitaly reaches v1.1.
......
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