pars_core/operation/
git.rs

1use std::path::Path;
2use std::process::{Command, Stdio};
3
4use anyhow::{anyhow, Result};
5pub fn git_io(executable: &str, work_dir: &Path, args: &[&str]) -> Result<()> {
6    let status = Command::new(executable)
7        .args(args)
8        .current_dir(work_dir)
9        .stdin(Stdio::inherit())
10        .stdout(Stdio::inherit())
11        .stderr(Stdio::inherit())
12        .spawn()?
13        .wait()?;
14
15    if status.success() {
16        Ok(())
17    } else {
18        Err(anyhow!(format!("Failed to run git command, code {:?}", status)))
19    }
20}