diff options
Diffstat (limited to 'lib/ci')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 98600a48d0f..0b362921b06 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -207,17 +207,15 @@ module Ci def matching?(patterns, ref, tag, source) patterns.any? do |pattern| - match_ref?(pattern, ref, tag, source) + match_ref?(pattern, ref, tag) || match_source?(pattern, source) end end - def match_ref?(pattern, ref, tag, source) + def match_ref?(pattern, ref, tag) pattern, path = pattern.split('@', 2) return false if path && path != self.path return true if tag && pattern == 'tags' return true if !tag && pattern == 'branches' - return true if source == 'trigger' && pattern == 'triggers' - return true if source == 'schedule' && pattern == 'schedules' if pattern.first == "/" && pattern.last == "/" Regexp.new(pattern[1...-1]) =~ ref @@ -225,5 +223,14 @@ module Ci pattern == ref end end + + def match_source?(pattern, source) + return source_to_pattern(source) == pattern + end + + def source_to_pattern(source) + return source if ['api', 'external', 'web'].include? source + return source.pluralize + end end end |