debian-mirror-gitlab/lib/gitlab/ci/build/policy/changes.rb

26 lines
603 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Build
module Policy
class Changes < Policy::Specification
def initialize(globs)
@globs = Array(globs)
end
2019-12-26 22:10:19 +05:30
def satisfied_by?(pipeline, context)
2019-07-07 11:18:12 +05:30
return true if pipeline.modified_paths.nil?
2018-12-05 23:21:45 +05:30
pipeline.modified_paths.any? do |path|
@globs.any? do |glob|
2019-02-15 15:39:39 +05:30
File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
2018-12-05 23:21:45 +05:30
end
end
end
end
end
end
end
end