gitlab-org--gitlab-foss/lib/gitlab/ci/build/policy/changes.rb

26 lines
603 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
module Ci
module Build
module Policy
class Changes < Policy::Specification
def initialize(globs)
@globs = Array(globs)
end
def satisfied_by?(pipeline, context)
return true if pipeline.modified_paths.nil?
pipeline.modified_paths.any? do |path|
@globs.any? do |glob|
2018-11-15 14:42:10 -05:00
File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
end
end
end
end
end
end
end
end