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

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
15
16
# 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?))
  @exact_globs, @pattern_globs = globs.partition(&method(:exact_glob?))
end

Instance Method Details

#satisfied_by?(pipeline, context) ⇒ Boolean

Returns:

  • (Boolean)

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

def satisfied_by?(pipeline, context)
  paths = worktree_paths(pipeline)

  exact_matches?(paths) || pattern_matches?(paths)
end