diff --git a/ext/code_ownership/src/lib.rs b/ext/code_ownership/src/lib.rs index 3805017..626c438 100644 --- a/ext/code_ownership/src/lib.rs +++ b/ext/code_ownership/src/lib.rs @@ -116,7 +116,7 @@ fn build_run_config() -> RunConfig { codeowners_file_path: None, config_path, no_cache: false, - executable_name: None, + executable_name: Some("bin/codeownership validate".to_string()), } } diff --git a/lib/code_ownership/code_ownership.bundle b/lib/code_ownership/code_ownership.bundle index 1ea578d..e2fa8ff 100755 Binary files a/lib/code_ownership/code_ownership.bundle and b/lib/code_ownership/code_ownership.bundle differ diff --git a/spec/lib/code_ownership_spec.rb b/spec/lib/code_ownership_spec.rb index 3666c1c..f0cf596 100644 --- a/spec/lib/code_ownership_spec.rb +++ b/spec/lib/code_ownership_spec.rb @@ -555,4 +555,28 @@ end end end + + describe '.validate!' do + context 'when the CODEOWNERS file is out of date' do + before do + create_non_empty_application + RustCodeOwners.generate_and_validate(nil, false) + # Add a new annotated file to make the CODEOWNERS file out of date + write_file('packs/my_pack/new_file.rb', "# @team Bar\nclass NewFile; end\n") + end + + it 'raises an error referencing bin/codeownership validate' do + expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error( + RuntimeError, + /Run `bin\/codeownership validate/ + ) + end + + it 'does not reference the standalone codeowners CLI' do + expect { CodeOwnership.validate!(autocorrect: false) }.to raise_error(RuntimeError) do |error| + expect(error.message).not_to include('`codeowners generate`') + end + end + end + end end