diff --git a/ext/code_ownership/Cargo.toml b/ext/code_ownership/Cargo.toml index c1f640b..5ec2816 100644 --- a/ext/code_ownership/Cargo.toml +++ b/ext/code_ownership/Cargo.toml @@ -17,7 +17,7 @@ rb-sys = { version = "0.9.111", features = [ magnus = { version = "0.7.1" } serde = { version = "1.0.219", features = ["derive"] } serde_magnus = "0.9.0" -codeowners = { git = "https://github.com/rubyatscale/codeowners-rs.git", tag = "v0.2.17" } +codeowners = { git = "https://github.com/rubyatscale/codeowners-rs.git", tag = "v0.3.0" } [dev-dependencies] rb-sys = { version = "0.9.117", features = [ diff --git a/ext/code_ownership/src/lib.rs b/ext/code_ownership/src/lib.rs index aa40e88..1e3ad14 100644 --- a/ext/code_ownership/src/lib.rs +++ b/ext/code_ownership/src/lib.rs @@ -74,15 +74,17 @@ fn version() -> String { runner::version() } -fn validate() -> Result { +fn validate(files: Option>) -> Result { let run_config = build_run_config(); - let run_result = runner::validate(&run_config, vec![]); + let files_vec = files.unwrap_or_default(); + let run_result = runner::validate(&run_config, files_vec); validate_result(&run_result) } -fn generate_and_validate(skip_stage: bool) -> Result { +fn generate_and_validate(files: Option>, skip_stage: bool) -> Result { let run_config = build_run_config(); - let run_result = runner::generate_and_validate(&run_config, vec![], skip_stage); + let files_vec = files.unwrap_or_default(); + let run_result = runner::generate_and_validate(&run_config, files_vec, skip_stage); validate_result(&run_result) } @@ -122,12 +124,11 @@ fn build_run_config() -> RunConfig { fn init(ruby: &Ruby) -> Result<(), Error> { let module = ruby.define_module("RustCodeOwners")?; module.define_singleton_method("for_file", function!(for_file, 1))?; - module.define_singleton_method("generate_and_validate", function!(generate_and_validate, 1))?; - module.define_singleton_method("validate", function!(validate, 0))?; + module.define_singleton_method("generate_and_validate", function!(generate_and_validate, 2))?; + module.define_singleton_method("validate", function!(validate, 1))?; module.define_singleton_method("for_team", function!(for_team, 1))?; module.define_singleton_method("version", function!(version, 0))?; module.define_singleton_method("teams_for_files", function!(teams_for_files, 1))?; Ok(()) } - diff --git a/lib/code_ownership.rb b/lib/code_ownership.rb index 8a9cb04..3116fad 100644 --- a/lib/code_ownership.rb +++ b/lib/code_ownership.rb @@ -233,9 +233,9 @@ def validate!( files: nil ) if autocorrect - ::RustCodeOwners.generate_and_validate(!stage_changes) + ::RustCodeOwners.generate_and_validate(files, !stage_changes) else - ::RustCodeOwners.validate + ::RustCodeOwners.validate(files) end end diff --git a/lib/code_ownership/code_ownership.bundle b/lib/code_ownership/code_ownership.bundle index ba0933a..f8d94bb 100755 Binary files a/lib/code_ownership/code_ownership.bundle and b/lib/code_ownership/code_ownership.bundle differ diff --git a/lib/code_ownership/version.rb b/lib/code_ownership/version.rb index d50e712..918b55c 100644 --- a/lib/code_ownership/version.rb +++ b/lib/code_ownership/version.rb @@ -1,5 +1,6 @@ +# typed: false # frozen_string_literal: true module CodeOwnership - VERSION = '2.0.0-4' + VERSION = '2.0.0-5' end diff --git a/sorbet/rbi/manual.rbi b/sorbet/rbi/manual.rbi index 1f0a301..fe77997 100644 --- a/sorbet/rbi/manual.rbi +++ b/sorbet/rbi/manual.rbi @@ -7,10 +7,10 @@ module RustCodeOwners def for_file(file) end - def generate_and_validate(skip_stage) + def generate_and_validate(files, skip_stage) end - def validate + def validate(files) end def for_team(team) diff --git a/spec/lib/code_ownership_spec.rb b/spec/lib/code_ownership_spec.rb index 66f7f3a..85e1c19 100644 --- a/spec/lib/code_ownership_spec.rb +++ b/spec/lib/code_ownership_spec.rb @@ -20,7 +20,7 @@ before do create_non_empty_application # codeowners-rs is matching files against the codeowners file - RustCodeOwners.generate_and_validate(false) + RustCodeOwners.generate_and_validate(nil, false) end context 'when no ownership is found' do @@ -92,7 +92,7 @@ before do create_non_empty_application # codeowners-rs is matching files against the codeowners file - RustCodeOwners.generate_and_validate(false) + RustCodeOwners.generate_and_validate(nil, false) end context 'when no ownership is found' do @@ -162,7 +162,7 @@ before do create_non_empty_application # codeowners-rs is matching files against the codeowners file for default path - RustCodeOwners.generate_and_validate(false) + RustCodeOwners.generate_and_validate(nil, false) end context 'when no ownership is found' do