Class: Gitlab::Ci::Build::Rules::Rule::Clause::Exists

Inherits:
Gitlab::Ci::Build::Rules::Rule::Clause show all
Defined in:
lib/gitlab/ci/build/rules/rule/clause/exists.rb

Constant Summary collapse

MAX_PATTERN_COMPARISONS =

The maximum number of patterned glob comparisons that will be performed before the rule assumes that it has a match

10_000

Constants inherited from Gitlab::Ci::Build::Rules::Rule::Clause

ParseError, UnknownClauseError

Instance Method Summary collapse

Methods inherited from Gitlab::Ci::Build::Rules::Rule::Clause

fabricate

Constructor Details

#initialize(globs) ⇒ Exists

Returns a new instance of Exists.



11
12
13
14
# File 'lib/gitlab/ci/build/rules/rule/clause/exists.rb', line 11

def initialize(globs)
  @globs = Array(globs)
  @top_level_only = @globs.all?(&method(:top_level_glob?))
end

Instance Method Details

#satisfied_by?(_pipeline, context) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/gitlab/ci/build/rules/rule/clause/exists.rb', line 16

def satisfied_by?(_pipeline, context)
  paths = worktree_paths(context)
  exact_globs, pattern_globs = separate_globs(context)

  exact_matches?(paths, exact_globs) || pattern_matches?(paths, pattern_globs)
end