diff options
author | Marius Bobin <mbobin@gitlab.com> | 2019-08-13 13:02:32 +0300 |
---|---|---|
committer | Marius Bobin <mbobin@gitlab.com> | 2019-08-21 14:34:18 +0300 |
commit | a328c8fdcd41a25b928f7cd18ad616f14f97a37a (patch) | |
tree | 5225095d432485f157d443327f88b3bd3274db04 /lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb | |
parent | cb73f4f03220c8edcb60b3c3056d6b4621e1e261 (diff) | |
download | gitlab-ce-a328c8fdcd41a25b928f7cd18ad616f14f97a37a.tar.gz |
Follow Ruby behavior when pattern matching nils
`=~` with nil must return false
`!~` with nil must return true
nil =~ /pattern/ #=> nil
nil =~ nil #=> nil
nil !~ /pattern/ #=> true
nil !~ nil #=> true
Diffstat (limited to 'lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb b/lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb index fe370d9b201..97dc4c7081a 100644 --- a/lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb +++ b/lib/gitlab/ci/pipeline/expression/lexeme/not_matches.rb @@ -10,7 +10,8 @@ module Gitlab def evaluate(variables = {}) text = @left.evaluate(variables) - regexp = @right.evaluate(variables) || '' + regexp = @right.evaluate(variables) + return true unless regexp regexp.scan(text.to_s).none? end |