Skip to content

Commit 55d8dbd

Browse files
committed
Simplify executable_path handling by using String directly
1 parent fa33ec1 commit 55d8dbd

File tree

3 files changed

+5
-43
lines changed

3 files changed

+5
-43
lines changed

src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ where
4747
pub(crate) fn config_from_run_config(run_config: &RunConfig) -> Result<Config, Error> {
4848
match crate::config::Config::load_from_path(&run_config.config_path) {
4949
Ok(mut c) => {
50-
if let Some(executable_name) = &run_config.executable_name() {
50+
if let Some(executable_name) = &run_config.executable_path {
5151
c.executable_name = executable_name.clone();
5252
}
5353
Ok(c)

src/runner/types.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use std::path::PathBuf;
44
use error_stack::Context;
55
use serde::{Deserialize, Serialize};
66

7-
use crate::path_utils::relative_to_buf;
8-
97
#[derive(Debug, Default, Serialize, Deserialize)]
108
pub struct RunResult {
119
pub validation_errors: Vec<String>,
@@ -19,15 +17,7 @@ pub struct RunConfig {
1917
pub codeowners_file_path: PathBuf,
2018
pub config_path: PathBuf,
2119
pub no_cache: bool,
22-
pub executable_path: Option<PathBuf>,
23-
}
24-
25-
impl RunConfig {
26-
pub fn executable_name(&self) -> Option<String> {
27-
self.executable_path
28-
.as_ref()
29-
.map(|path| relative_to_buf(&self.project_root, path).to_string_lossy().to_string())
30-
}
20+
pub executable_path: Option<String>,
3121
}
3222

3323
#[derive(Debug, Serialize)]

tests/run_config_executable_override_test.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::error::Error;
2-
use std::path::{Path, PathBuf};
2+
use std::path::Path;
33

44
mod common;
55
use common::{build_run_config, git_add_all_files, setup_fixture_repo};
@@ -18,7 +18,7 @@ fn test_run_config_executable_path_overrides_config_file() -> Result<(), Box<dyn
1818

1919
let mut run_config = build_run_config(project_path, ".github/CODEOWNERS");
2020
// Use a relative path that gets displayed as-is in error messages
21-
run_config.executable_path = Some(PathBuf::from("my-wrapper-tool"));
21+
run_config.executable_path = Some("my-wrapper-tool".to_string());
2222

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

@@ -78,7 +78,7 @@ fn test_run_config_executable_path_overrides_default() -> Result<(), Box<dyn Err
7878
// This fixture has NO executable_name in config (uses default "codeowners")
7979

8080
let mut run_config = build_run_config(project_path, ".github/CODEOWNERS");
81-
run_config.executable_path = Some(PathBuf::from("custom-command"));
81+
run_config.executable_path = Some("custom-command".to_string());
8282

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

@@ -97,31 +97,3 @@ fn test_run_config_executable_path_overrides_default() -> Result<(), Box<dyn Err
9797

9898
Ok(())
9999
}
100-
101-
#[test]
102-
fn test_executable_name_extraction_from_path() {
103-
use codeowners::runner::RunConfig;
104-
105-
let mut run_config = RunConfig {
106-
project_root: PathBuf::from("."),
107-
codeowners_file_path: PathBuf::from(".github/CODEOWNERS"),
108-
config_path: PathBuf::from("config/code_ownership.yml"),
109-
no_cache: true,
110-
executable_path: None,
111-
};
112-
113-
// Test with None
114-
assert_eq!(run_config.executable_name(), None);
115-
116-
// Test with simple path (no directory component)
117-
run_config.executable_path = Some(PathBuf::from("codeowners"));
118-
assert_eq!(run_config.executable_name(), Some("codeowners".to_string()));
119-
120-
// Test with relative path - returns full relative path string
121-
run_config.executable_path = Some(PathBuf::from("bin/codeownership"));
122-
assert_eq!(run_config.executable_name(), Some("bin/codeownership".to_string()));
123-
124-
// Test with another relative path
125-
run_config.executable_path = Some(PathBuf::from("tools/my-tool"));
126-
assert_eq!(run_config.executable_name(), Some("tools/my-tool".to_string()));
127-
}

0 commit comments

Comments
 (0)