Skip to content
Snippets Groups Projects
Commit 32b8e2f3 authored by Carl P. Corliss's avatar Carl P. Corliss
Browse files

rubocop fixes

parent 7151b3d0
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !179308. Comments created here will be created in the context of that merge request.
......@@ -5,6 +5,8 @@ module Ci
module Build
module Policy
class Changes < Policy::Specification
FNMATCH_FLAGS = File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB
def initialize(globs)
@globs = Array(globs)
end
......@@ -18,18 +20,18 @@ def satisfied_by?(pipeline, context)
positive_matches = []
@globs.each do |glob|
if glob.start_with?('!') # negative glob pattern
negative_matches << File.fnmatch?(glob[1..], path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
if glob.start_with?('!')
negative_matches << File.fnmatch?(glob[1..], path, FNMATCH_FLAGS)
else
positive_matches << File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB)
positive_matches << File.fnmatch?(glob, path, FNMATCH_FLAGS)
end
end
if positive_matches.empty? && negative_matches.empty?
# Path doesn't match any of our patterns, so not a match
false
false
elsif positive_matches.empty?
# No positive matches means that we were only supplied negated patterns.
# No positive matches means that we were only supplied negated patterns.
# Which is the same as saying "Allow all EXCEPT these (negated) globs." So,
# if none of our negated globs matched, then the path is okay to allow.
!negative_matches.any?
......@@ -43,4 +45,4 @@ def satisfied_by?(pipeline, context)
end
end
end
end
\ No newline at end of file
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment