diff options
author | Filip Krakowski <Filip.Krakowski@Uni-Duesseldorf.de> | 2017-06-02 19:02:56 +0200 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-06-08 00:34:58 +0900 |
commit | ecb54cddd164fbf83288d7903c4692df462bae5e (patch) | |
tree | 992908751c781851a8c8b63194132b3b2d59e6f7 /lib/ci | |
parent | 8db63b26284d949000316a38676ef6fad970f657 (diff) | |
download | gitlab-ce-ecb54cddd164fbf83288d7903c4692df462bae5e.tar.gz |
Add all sources as special keywords for only and except
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 |