2018-10-02 09:59:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-02 08:48:18 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
module Policy
|
|
|
|
class Changes < Policy::Specification
|
|
|
|
def initialize(globs)
|
|
|
|
@globs = Array(globs)
|
|
|
|
end
|
|
|
|
|
2019-11-17 16:06:14 -05:00
|
|
|
def satisfied_by?(pipeline, context)
|
2019-02-13 05:59:34 -05:00
|
|
|
return true if pipeline.modified_paths.nil?
|
2018-10-02 08:48:18 -04:00
|
|
|
|
|
|
|
pipeline.modified_paths.any? do |path|
|
2018-10-02 09:04:32 -04:00
|
|
|
@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)
|
2018-10-02 09:04:32 -04:00
|
|
|
end
|
2018-10-02 08:48:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|