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
|
|
|
|
|
|
|
|
def satisfied_by?(pipeline, seed)
|
|
|
|
return true unless pipeline.branch_updated?
|
|
|
|
|
|
|
|
pipeline.modified_paths.any? do |path|
|
2018-10-02 09:04:32 -04:00
|
|
|
@globs.any? do |glob|
|
|
|
|
File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
|
|
|
|
end
|
2018-10-02 08:48:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|