BigW Consortium Gitlab

Commit 6681ea9c by Grzegorz Bizon

Simplify pipeline source policy pattern matching

parent a04cbd5b
...@@ -27,7 +27,8 @@ module Gitlab ...@@ -27,7 +27,8 @@ module Gitlab
def matches_pattern?(pattern, pipeline) def matches_pattern?(pattern, pipeline)
return true if pipeline.tag? && pattern == 'tags' return true if pipeline.tag? && pattern == 'tags'
return true if pipeline.branch? && pattern == 'branches' return true if pipeline.branch? && pattern == 'branches'
return true if source_to_pattern(pipeline.source) == pattern return true if pipeline.source == pattern
return true if pipeline.source&.pluralize == pattern
if pattern.first == "/" && pattern.last == "/" if pattern.first == "/" && pattern.last == "/"
Regexp.new(pattern[1...-1]) =~ pipeline.ref Regexp.new(pattern[1...-1]) =~ pipeline.ref
...@@ -35,14 +36,6 @@ module Gitlab ...@@ -35,14 +36,6 @@ module Gitlab
pattern == pipeline.ref pattern == pipeline.ref
end end
end end
def source_to_pattern(source)
if %w[api external web].include?(source)
source
else
source&.pluralize
end
end
end end
end end
end end
......
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