-use std::io::Result;
+use std::io::{Error, ErrorKind::Other, Result};
use std::path::PathBuf;
-use std::process::Command;
+use std::process::{Command, Stdio};
use std::time::{SystemTime, UNIX_EPOCH};
pub struct Git;
fn sync_up(&self, remote: &str, directory: &PathBuf) -> Result<()> {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH)
- .expect("Invalid time")
+ .map_err(|_| Error::new(Other, "Invalid time"))?
.as_millis();
let commands = vec![
Command::new("sh")
.arg("-c")
.arg(&command)
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
.status()
- .expect("Failed while performing sync up with git");
+ .map_err(|_| Error::new(Other, "Failed while performing sync up with git"))?;
}
Ok(())
Command::new("sh")
.arg("-c")
.arg(&command)
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
.status()
- .expect("Failed while performing sync down with git");
+ .map_err(|_| Error::new(Other, "Failed while performing sync down with git"))?;
}
Ok(())
}