lib/codeowners/checker/group/pattern.rb in codeowners-checker-1.0.3 vs lib/codeowners/checker/group/pattern.rb in codeowners-checker-1.0.4

- old
+ new

@@ -31,13 +31,17 @@ @pattern, *@owners = line.split(/\s+/) @whitespace = line.split('@').first.count(' ') - 1 end def match_file?(file) - if !pattern.include?('/') || pattern.include?('**') - File.fnmatch(pattern.gsub(%r{^/}, ''), file, File::FNM_DOTMATCH) + File.fnmatch(pattern.gsub(%r{^/}, ''), file, fn_options) + end + + def fn_options + if pattern.include?('**') + File::FNM_DOTMATCH else - File.fnmatch(pattern.gsub(%r{^/}, ''), file, File::FNM_PATHNAME | File::FNM_DOTMATCH) + File::FNM_DOTMATCH | File::FNM_PATHNAME end end def pattern=(new_pattern) @whitespace += @pattern.size - new_pattern.size