Skip to content
Snippets Groups Projects

Fix CI rules-if comparison with Regexp variables

Merged Furkan Ayhan requested to merge 35438-ci-variable-comparison-with-regexp into master
5 files
+ 67
11
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -11,8 +11,15 @@ class Matches < Lexeme::LogicalOperator
@@ -11,8 +11,15 @@ class Matches < Lexeme::LogicalOperator
def evaluate(variables = {})
def evaluate(variables = {})
text = @left.evaluate(variables)
text = @left.evaluate(variables)
regexp = @right.evaluate(variables)
regexp = @right.evaluate(variables)
 
return false unless regexp
return false unless regexp
 
if ::Feature.enabled?(:ci_fix_rules_if_comparison_with_regexp_variable)
 
# All variables are evaluated as strings, even if they are regexp strings.
 
# So, we need to convert them to regexp objects.
 
regexp = Lexeme::Pattern.build_and_evaluate(regexp, variables)
 
end
 
regexp.scan(text.to_s).present?
regexp.scan(text.to_s).present?
end
end
Loading