manager: Fix ignoring subcommand exit status
This commit is contained in:
parent
9198ffa10a
commit
cf484fe21c
|
@ -2,6 +2,19 @@ use std::process::Command;
|
|||
|
||||
use anyhow::Context as _;
|
||||
|
||||
trait SuccessExt {
|
||||
fn success(&mut self) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
impl SuccessExt for Command {
|
||||
fn success(&mut self) -> anyhow::Result<()> {
|
||||
if !self.status()?.success() {
|
||||
anyhow::bail!("Command returned unsuccessfully");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn render_and_publish(
|
||||
tree: &crate::tree::Tree,
|
||||
timestamp: &str,
|
||||
|
@ -20,7 +33,7 @@ pub async fn render_and_publish(
|
|||
.arg("-C")
|
||||
.arg(&render_repo)
|
||||
.arg("init")
|
||||
.status()
|
||||
.success()
|
||||
.context("Failed to initialize render repository")?;
|
||||
|
||||
let dot_file = render_repo.join("techtree.dot");
|
||||
|
@ -35,7 +48,7 @@ pub async fn render_and_publish(
|
|||
.arg("-o")
|
||||
.arg(&svg_file)
|
||||
.arg(&dot_file)
|
||||
.status()
|
||||
.success()
|
||||
.context("Failed to generate svg graph from dot source")?;
|
||||
|
||||
Command::new("git")
|
||||
|
@ -44,7 +57,7 @@ pub async fn render_and_publish(
|
|||
.arg("add")
|
||||
.arg(dot_file.file_name().unwrap())
|
||||
.arg(svg_file.file_name().unwrap())
|
||||
.status()
|
||||
.success()
|
||||
.context("Failed to add generated graph files to git index")?;
|
||||
|
||||
Command::new("git")
|
||||
|
@ -52,7 +65,7 @@ pub async fn render_and_publish(
|
|||
.arg(&render_repo)
|
||||
.arg("commit")
|
||||
.args(["-m", &format!("Updated techtree at {timestamp}")])
|
||||
.status()
|
||||
.success()
|
||||
.context("Failed to add generated graph files to git index")?;
|
||||
|
||||
Command::new("git")
|
||||
|
|
Loading…
Reference in a new issue