Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn vendored_gems_path() -> String {
}

fn default_executable_name() -> String {
"codeowners".to_string()
"codeowners generate".to_string()
}

fn default_ignore_dirs() -> Vec<String> {
Expand Down Expand Up @@ -134,7 +134,7 @@ mod tests {
vec!["frontend/**/node_modules/**/*", "frontend/**/__generated__/**/*"]
);
assert_eq!(config.vendored_gems_path, "vendored/");
assert_eq!(config.executable_name, "codeowners");
assert_eq!(config.executable_name, "codeowners generate");
Ok(())
}

Expand Down Expand Up @@ -167,7 +167,7 @@ mod tests {
fs::write(&config_path, config_str)?;
let config_file = File::open(&config_path)?;
let config: Config = serde_yaml::from_reader(config_file)?;
assert_eq!(config.executable_name, "codeowners");
assert_eq!(config.executable_name, "codeowners generate");
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/ownership/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Error {
Error::FileWithoutOwner { path: _ } => "Some files are missing ownership".to_owned(),
Error::FileWithMultipleOwners { path: _, owners: _ } => "Code ownership should only be defined for each file in one way. The following files have declared ownership in multiple ways".to_owned(),
Error::CodeownershipFileIsStale { executable_name } => {
format!("CODEOWNERS out of date. Run `{} generate` to update the CODEOWNERS file", executable_name)
format!("CODEOWNERS out of date. Run `{}` to update the CODEOWNERS file", executable_name)
}
Error::InvalidTeam { name: _, path: _ } => "Found invalid team annotations".to_owned(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod tests {
codeowners_file_path: PathBuf::from(".github/CODEOWNERS"),
directory_codeowner_files: vec![],
teams_by_name: HashMap::new(),
executable_name: "codeowners".to_string(),
executable_name: "codeowners generate".to_string(),
};

let map = project.vendored_gem_by_name();
Expand Down
4 changes: 2 additions & 2 deletions tests/executable_name_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn test_validate_with_custom_executable_name() -> Result<(), Box<dyn Error>> {
&["validate"],
false,
OutputStream::Stdout,
predicate::str::contains("Run `bin/codeownership generate`"),
predicate::str::contains("Run `bin/codeownership validate`"),
)?;
Ok(())
}
Expand Down Expand Up @@ -42,7 +42,7 @@ fn test_custom_executable_name_full_error_message() -> Result<(), Box<dyn Error>
OutputStream::Stdout,
predicate::eq(indoc! {"

CODEOWNERS out of date. Run `bin/codeownership generate` to update the CODEOWNERS file
CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file

"}),
)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
owned_globs:
- "{app,config}/**/*.rb"
executable_name: "bin/codeownership"
executable_name: "bin/codeownership validate"
27 changes: 13 additions & 14 deletions tests/run_config_executable_override_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ fn test_run_config_executable_path_overrides_config_file() -> Result<(), Box<dyn
let project_path = temp_dir.path();
git_add_all_files(project_path);

// This fixture has executable_name: "bin/codeownership" in config
// But we'll override it with RunConfig.executable_path
// This fixture has executable_name: "bin/codeownership validate" in config
// But we'll override it with RunConfig.executable_name

let mut run_config = build_run_config(project_path, ".github/CODEOWNERS");
// Use a relative path that gets displayed as-is in error messages
run_config.executable_name = Some("my-wrapper-tool".to_string());
run_config.executable_name = Some("my-wrapper-tool validate".to_string());

let result = validate(&run_config, vec![]);

// Should use "my-wrapper-tool" from executable_path, NOT "bin/codeownership" from config
// Should use "my-wrapper-tool validate" from RunConfig, NOT "bin/codeownership validate" from config
assert!(!result.validation_errors.is_empty(), "Expected validation errors but got none");
let error_msg = result.validation_errors.join("\n");
assert!(
error_msg.contains("Run `my-wrapper-tool generate`"),
"Expected error to contain 'my-wrapper-tool generate' but got: {}",
error_msg.contains("Run `my-wrapper-tool validate`"),
"Expected error to contain 'my-wrapper-tool validate' but got: {}",
error_msg
);
assert!(
Expand All @@ -47,19 +46,19 @@ fn test_run_config_without_executable_path_uses_config_file() -> Result<(), Box<
let project_path = temp_dir.path();
git_add_all_files(project_path);

// This fixture has executable_name: "bin/codeownership" in config
// This fixture has executable_name: "bin/codeownership validate" in config

let mut run_config = build_run_config(project_path, ".github/CODEOWNERS");
run_config.executable_name = None; // Explicitly no override

let result = validate(&run_config, vec![]);

// Should use "bin/codeownership" from config file
// Should use "bin/codeownership validate" from config file
assert!(!result.validation_errors.is_empty(), "Expected validation errors but got none");
let error_msg = result.validation_errors.join("\n");
assert!(
error_msg.contains("Run `bin/codeownership generate`"),
"Expected error to contain 'bin/codeownership generate' but got: {}",
error_msg.contains("Run `bin/codeownership validate`"),
"Expected error to contain 'bin/codeownership validate' but got: {}",
error_msg
);

Expand All @@ -75,14 +74,14 @@ fn test_run_config_executable_path_overrides_default() -> Result<(), Box<dyn Err
let project_path = temp_dir.path();
git_add_all_files(project_path);

// This fixture has NO executable_name in config (uses default "codeowners")
// This fixture has NO executable_name in config (uses default "codeowners generate")

let mut run_config = build_run_config(project_path, ".github/CODEOWNERS");
run_config.executable_name = Some("custom-command".to_string());
run_config.executable_name = Some("custom-command generate".to_string());

let result = validate(&run_config, vec![]);

// Should use "custom-command" from executable_path, NOT default "codeowners"
// Should use "custom-command generate" from RunConfig, NOT default "codeowners generate"
assert!(!result.validation_errors.is_empty(), "Expected validation errors but got none");
let error_msg = result.validation_errors.join("\n");
assert!(
Expand Down