diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-11-23 12:27:08 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-11-26 11:15:18 +0100 |
commit | 4b7e9eaacd3c5ecfb6e8e28a0d36832d1627515a (patch) | |
tree | 043d0eaea7d0d4181066e6204685e35583685509 | |
parent | 5f0e4040ce7d4d0019b3340dd603cc6f67dd036d (diff) | |
download | gitlab-ce-4b7e9eaacd3c5ecfb6e8e28a0d36832d1627515a.tar.gz |
Treat Repository instances with the same disk path as the same hash keydm-batch-loader-key
-rw-r--r-- | app/models/repository.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/diff/diff_refs.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 8 |
3 files changed, 15 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index fff6d4be275..a77fa8f2ce7 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -69,7 +69,13 @@ class Repository end 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 def raw_repository diff --git a/lib/gitlab/diff/diff_refs.rb b/lib/gitlab/diff/diff_refs.rb index d4823f60826..dc245377ccc 100644 --- a/lib/gitlab/diff/diff_refs.rb +++ b/lib/gitlab/diff/diff_refs.rb @@ -23,7 +23,7 @@ module Gitlab alias_method :eql?, :== def hash - [base_sha, start_sha, head_sha].hash + [self.class, base_sha, start_sha, head_sha].hash end # There is only one case in which we will have `start_sha` and `head_sha`, diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 067f4026f48..9b48031b2d3 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -80,7 +80,13 @@ module Gitlab end 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 # This method will be removed when Gitaly reaches v1.1. |