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 _;
|
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(
|
pub async fn render_and_publish(
|
||||||
tree: &crate::tree::Tree,
|
tree: &crate::tree::Tree,
|
||||||
timestamp: &str,
|
timestamp: &str,
|
||||||
|
@ -20,7 +33,7 @@ pub async fn render_and_publish(
|
||||||
.arg("-C")
|
.arg("-C")
|
||||||
.arg(&render_repo)
|
.arg(&render_repo)
|
||||||
.arg("init")
|
.arg("init")
|
||||||
.status()
|
.success()
|
||||||
.context("Failed to initialize render repository")?;
|
.context("Failed to initialize render repository")?;
|
||||||
|
|
||||||
let dot_file = render_repo.join("techtree.dot");
|
let dot_file = render_repo.join("techtree.dot");
|
||||||
|
@ -35,7 +48,7 @@ pub async fn render_and_publish(
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(&svg_file)
|
.arg(&svg_file)
|
||||||
.arg(&dot_file)
|
.arg(&dot_file)
|
||||||
.status()
|
.success()
|
||||||
.context("Failed to generate svg graph from dot source")?;
|
.context("Failed to generate svg graph from dot source")?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
|
@ -44,7 +57,7 @@ pub async fn render_and_publish(
|
||||||
.arg("add")
|
.arg("add")
|
||||||
.arg(dot_file.file_name().unwrap())
|
.arg(dot_file.file_name().unwrap())
|
||||||
.arg(svg_file.file_name().unwrap())
|
.arg(svg_file.file_name().unwrap())
|
||||||
.status()
|
.success()
|
||||||
.context("Failed to add generated graph files to git index")?;
|
.context("Failed to add generated graph files to git index")?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
|
@ -52,7 +65,7 @@ pub async fn render_and_publish(
|
||||||
.arg(&render_repo)
|
.arg(&render_repo)
|
||||||
.arg("commit")
|
.arg("commit")
|
||||||
.args(["-m", &format!("Updated techtree at {timestamp}")])
|
.args(["-m", &format!("Updated techtree at {timestamp}")])
|
||||||
.status()
|
.success()
|
||||||
.context("Failed to add generated graph files to git index")?;
|
.context("Failed to add generated graph files to git index")?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
|
|
Loading…
Reference in a new issue