Commit 1736a2da authored by Filip Krakowski's avatar Filip Krakowski Committed by Shinya Maeda

Fix change in behavior

parent 7d16f698
...@@ -207,15 +207,19 @@ module Ci ...@@ -207,15 +207,19 @@ module Ci
def matching?(patterns, ref, tag, source) def matching?(patterns, ref, tag, source)
patterns.any? do |pattern| patterns.any? do |pattern|
match_ref?(pattern, ref, tag) || match_source?(pattern, source) pattern, path = pattern.split('@', 2)
match_path?(path) && match_pattern?(pattern, ref, tag, source)
end end
end end
def match_ref?(pattern, ref, tag) def match_path?(path)
pattern, path = pattern.split('@', 2) return !(path && path != self.path)
return false if path && path != self.path end
def match_pattern?(pattern, ref, tag, source)
return true if tag && pattern == 'tags' return true if tag && pattern == 'tags'
return true if !tag && pattern == 'branches' return true if !tag && pattern == 'branches'
return true if source_to_pattern(source) == pattern
if pattern.first == "/" && pattern.last == "/" if pattern.first == "/" && pattern.last == "/"
Regexp.new(pattern[1...-1]) =~ ref Regexp.new(pattern[1...-1]) =~ ref
...@@ -224,10 +228,6 @@ module Ci ...@@ -224,10 +228,6 @@ module Ci
end end
end end
def match_source?(pattern, source)
return source_to_pattern(source) == pattern
end
def source_to_pattern(source) def source_to_pattern(source)
return source if %w(api external web).include?(source) || source.nil? return source if %w(api external web).include?(source) || source.nil?
return source.pluralize return source.pluralize
......
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