Class: Gitlab::Ci::Build::Policy::Changes

Inherits:
Specification show all
Defined in:
lib/gitlab/ci/build/policy/changes.rb

Constant Summary

Constants inherited from Specification

Specification::UnknownPolicyError

Instance Method Summary collapse

Constructor Details

#initialize(globs) ⇒ Changes

Returns a new instance of Changes.


8
9
10
# File 'lib/gitlab/ci/build/policy/changes.rb', line 8

def initialize(globs)
  @globs = Array(globs)
end

Instance Method Details

#satisfied_by?(pipeline, context) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/ci/build/policy/changes.rb', line 12

def satisfied_by?(pipeline, context)
  return true if pipeline.modified_paths.nil?

  pipeline.modified_paths.any? do |path|
    @globs.any? do |glob|
      File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
    end
  end
end