diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-09-18 14:00:59 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-09-18 14:00:59 +0200 |
commit | 6681ea9cd8d7001a352c95237d625057b6147f0b (patch) | |
tree | d8b9f9ab00e1f55b76001b3a030a0e5787fbf965 | |
parent | a04cbd5bb52dbaf6d0b05eca5215400f30051974 (diff) | |
download | gitlab-ce-6681ea9cd8d7001a352c95237d625057b6147f0b.tar.gz |
Simplify pipeline source policy pattern matching
-rw-r--r-- | lib/gitlab/ci/build/policy/refs.rb | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/gitlab/ci/build/policy/refs.rb b/lib/gitlab/ci/build/policy/refs.rb index 641c2e510be..76a57f041e3 100644 --- a/lib/gitlab/ci/build/policy/refs.rb +++ b/lib/gitlab/ci/build/policy/refs.rb @@ -27,7 +27,8 @@ module Gitlab def matches_pattern?(pattern, pipeline) return true if pipeline.tag? && pattern == 'tags' 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 == "/" Regexp.new(pattern[1...-1]) =~ pipeline.ref @@ -35,14 +36,6 @@ module Gitlab pattern == pipeline.ref end end - - def source_to_pattern(source) - if %w[api external web].include?(source) - source - else - source&.pluralize - end - end end end end |