Skip to content

Commit 7cd5039

Browse files
author
Alex Evanczuk
authored
Fix bug associated with validate when input file is unowned (#60)
* Fix bug associated with validate when input file is unowned * bump version
1 parent a0cb927 commit 7cd5039

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
code_ownership (1.32.12)
4+
code_ownership (1.32.13)
55
code_teams (~> 1.0)
66
packs
77
sorbet-runtime

code_ownership.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'code_ownership'
3-
spec.version = '1.32.12'
3+
spec.version = '1.32.13'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'

lib/code_ownership/private.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def self.file_tracked?(file)
9292
File.fnmatch?(owned_glob, file, File::FNM_PATHNAME | File::FNM_EXTGLOB)
9393
end
9494

95-
in_unowned_globs = configuration.unowned_globs.all? do |unowned_glob|
95+
in_unowned_globs = configuration.unowned_globs.any? do |unowned_glob|
9696
File.fnmatch?(unowned_glob, file, File::FNM_PATHNAME | File::FNM_EXTGLOB)
9797
end
9898

spec/lib/code_ownership_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@
6666
end
6767
end
6868
end
69+
70+
context 'file is unowned' do
71+
before do
72+
write_file('config/teams/bar.yml', <<~CONTENTS)
73+
name: Bar
74+
CONTENTS
75+
76+
write_configuration
77+
78+
write_file('app/services/autogenerated_code/some_unowned_file.rb', '')
79+
end
80+
81+
it 'has no validation errors' do
82+
expect { CodeOwnership.validate!(files: ['app/services/autogenerated_code/some_unowned_file.rb']) }.to raise_error do |e|
83+
expect(e.message).to eq <<~MSG.chomp
84+
Some files are missing ownership:
85+
86+
- app/services/autogenerated_code/some_unowned_file.rb
87+
88+
See https://github.com/rubyatscale/code_ownership#README.md for more details
89+
MSG
90+
end
91+
end
92+
93+
context 'ignored file passed in that is ignored' do
94+
before do
95+
write_configuration('unowned_globs' => ['app/services/autogenerated_code/**/**', 'vendor/bundle/**/**'])
96+
end
97+
98+
it 'has no validation errors' do
99+
expect { CodeOwnership.validate!(files: ['app/services/autogenerated_code/some_unowned_file.rb']) }.to_not raise_error
100+
end
101+
end
102+
end
69103
end
70104

71105
# See tests for individual ownership_mappers to understand behavior for each mapper

0 commit comments

Comments
 (0)