Skip to content

Commit

Permalink
fix: properly fail if --get_paths cmd fails
Browse files Browse the repository at this point in the history
  • Loading branch information
suo committed Feb 7, 2024
1 parent b1feb93 commit 53c4961
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
.output()
.context("failed to run provided paths_cmd")?;

ensure!(
output.status.success(),
format!("Failed to run provided paths_cmd: '{}'", paths_cmd)
);

let files = std::str::from_utf8(&output.stdout).context("failed to parse paths_cmd output")?;
let files = files
.lines()
Expand Down Expand Up @@ -331,6 +336,12 @@ mod tests {
Ok(())
}

#[test]
fn invalid_get_paths_from_cmd_fails() -> () {
assert!(get_paths_from_cmd("asoidjfoaisdjf").is_err());
assert!(get_paths_from_cmd("false").is_err());
}

#[test]
fn merge_base_with() -> Result<()> {
let git = GitCheckout::new()?;
Expand Down

0 comments on commit 53c4961

Please sign in to comment.