diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-10 17:20:27 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 22:49:41 +0200 |
commit | bb5187bb2a71f87b3ff49388f70dbcb27dfe4c6a (patch) | |
tree | 3049fc8a014ea93fdee87d1cb3ac9eefd8ea88c6 /app/models/concerns | |
parent | 8f6dac4991ba7f5771a24175784f19dc1bbd4103 (diff) | |
download | gitlab-ce-bb5187bb2a71f87b3ff49388f70dbcb27dfe4c6a.tar.gz |
Handle case where 2 matches in the same tree are found
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/group_hierarchy.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/concerns/group_hierarchy.rb b/app/models/concerns/group_hierarchy.rb index f7a62c9a607..9999bd87686 100644 --- a/app/models/concerns/group_hierarchy.rb +++ b/app/models/concerns/group_hierarchy.rb @@ -62,7 +62,12 @@ module GroupHierarchy # If both of them are hashes, we can deep_merge with the same logic elsif first_child.is_a?(Hash) && second_child.is_a?(Hash) first_child.deep_merge(second_child) { |key, first, second| merge_values(first, second) } - # One of them is a root node, we just need to put them next to eachother in an array + # If only one of them is a hash, we can check if the other child is already + # included, we don't need to do anything when it is. + elsif first_child.is_a?(Hash) && first_child.keys.include?(second_child) + first_child + elsif second_child.is_a?(Hash) && second_child.keys.include?(first_child) + second_child else Array.wrap(first_child) + Array.wrap(second_child) end |