X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/172f4c8807d44ebe38c7f227b7fdc2d6a9dbe323..50f53dc480fda8b3daab7a34454c2dd9f3f5f991:/src/remote/git.rs diff --git a/src/remote/git.rs b/src/remote/git.rs index a4c1c28..66c5a89 100644 --- a/src/remote/git.rs +++ b/src/remote/git.rs @@ -1,6 +1,6 @@ -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; @@ -19,7 +19,7 @@ impl super::Remote for 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![ @@ -33,8 +33,10 @@ impl super::Remote for Git { 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(()) @@ -52,8 +54,10 @@ impl super::Remote for Git { 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(()) }