Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/code_ownership/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
15 changes: 8 additions & 7 deletions ext/code_ownership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ fn version() -> String {
runner::version()
}

fn validate() -> Result<Value, Error> {
fn validate(files: Option<Vec<String>>) -> Result<Value, Error> {
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<Value, Error> {
fn generate_and_validate(files: Option<Vec<String>>, skip_stage: bool) -> Result<Value, Error> {
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)
}

Expand Down Expand Up @@ -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(())
}

4 changes: 2 additions & 2 deletions lib/code_ownership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file modified lib/code_ownership/code_ownership.bundle
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/code_ownership/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# typed: false
# frozen_string_literal: true

module CodeOwnership
VERSION = '2.0.0-4'
VERSION = '2.0.0-5'
end
4 changes: 2 additions & 2 deletions sorbet/rbi/manual.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/code_ownership_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down