Better error handling (fixes #15)

This commit is contained in:
Roey Darwish Dror
2018-06-06 15:32:38 +03:00
parent 3897b2ac76
commit ef69dc01ba
4 changed files with 254 additions and 142 deletions

View File

@@ -1,3 +1,4 @@
use super::Check;
use failure::Error;
use std::path::{Path, PathBuf};
use std::process::Command;
@@ -38,17 +39,18 @@ impl Git {
None
}
pub fn pull<P: AsRef<Path>>(&self, path: P) -> Result<Option<bool>, Error> {
pub fn pull<P: AsRef<Path>>(&self, path: P) -> Result<Option<()>, Error> {
if let Some(git) = &self.git {
if let Ok(mut command) = Command::new(&git)
Command::new(&git)
.arg("pull")
.arg("--rebase")
.arg("--autostash")
.current_dir(path)
.spawn()
{
return Ok(Some(command.wait()?.success()));
}
.spawn()?
.wait()?
.check()?;
return Ok(Some(()));
}
Ok(None)