File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def self.file_tracked?(file)
9292 # However, globbing out can take 5 or more seconds on a large repository, dramatically slowing down
9393 # invocations to `bin/codeownership validate --diff`.
9494 # Using `File.fnmatch?` is a lot faster!
95- in_owned_globs = configuration . owned_globs . all ? do |owned_glob |
95+ in_owned_globs = configuration . owned_globs . any ? do |owned_glob |
9696 File . fnmatch? ( owned_glob , file , File ::FNM_PATHNAME | File ::FNM_EXTGLOB )
9797 end
9898
Original file line number Diff line number Diff line change 33
44 describe 'validate' do
55 let ( :argv ) { [ 'validate' ] }
6+ let ( :owned_globs ) { nil }
67
78 before do
8- write_configuration
9+ write_configuration ( owned_globs : owned_globs )
910 write_file ( 'app/services/my_file.rb' )
1011 write_file ( 'frontend/javascripts/my_file.jsx' )
1112 end
2122 end
2223 end
2324
25+ context 'with --diff argument' do
26+ let ( :argv ) { [ 'validate' , '--diff' ] }
27+
28+ before do
29+ allow ( ENV ) . to receive ( :fetch ) . and_call_original
30+ allow ( ENV ) . to receive ( :fetch ) . with ( 'CODEOWNERS_GIT_STAGED_FILES' ) . and_return ( 'app/services/my_file.rb' )
31+ end
32+
33+ context 'when there are multiple owned_globs' do
34+ let ( :owned_globs ) { [ 'app/*/**' , 'lib/*/**' ] }
35+
36+ it 'validates the tracked file' do
37+ expect { subject } . to raise_error CodeOwnership ::InvalidCodeOwnershipConfigurationError
38+ end
39+ end
40+ end
2441 end
2542
2643 describe 'for_file' do
You can’t perform that action at this time.
0 commit comments