summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-02-25 20:05:26 +0900
committerShinya Maeda <shinya@gitlab.com>2019-03-01 22:52:38 +0900
commitf62dc67d262792829bdcaef779b3915e9cc93a4f (patch)
treef9419e96914addb59dfa4ab653c9c6151b33e4e2 /lib
parentdc5fc28382246fbbe2bb6f61fe8dac136b5f3189 (diff)
downloadgitlab-ce-f62dc67d262792829bdcaef779b3915e9cc93a4f.tar.gz
Add suffix for merge request event
Fix ok Add spec Fix ok Fix Add changelog Fix Add memoization a fix
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/build/policy/refs.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/ci/build/policy/refs.rb b/lib/gitlab/ci/build/policy/refs.rb
index 0e9bb5c94bb..df5f5ffc253 100644
--- a/lib/gitlab/ci/build/policy/refs.rb
+++ b/lib/gitlab/ci/build/policy/refs.rb
@@ -29,8 +29,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 pipeline.source == pattern
- return true if pipeline.source&.pluralize == pattern
+ return true if sanitized_source_name(pipeline) == pattern
+ return true if sanitized_source_name(pipeline)&.pluralize == pattern
# patterns can be matched only when branch or tag is used
# the pattern matching does not work for merge requests pipelines
@@ -42,6 +42,10 @@ module Gitlab
end
end
end
+
+ def sanitized_source_name(pipeline)
+ @sanitized_source_name ||= pipeline&.source&.delete_suffix('_event')
+ end
end
end
end