diff --git a/src/executor.rs b/src/executor.rs index d952e758..055e03ca 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -229,7 +229,7 @@ impl CommandExt for Command { trace!("Output of {:?}: {:?}", self, output); let status = output.status; if !status.success() { - Err(ErrorKind::ProcessFailed(status))? + return Err(ErrorKind::ProcessFailed(status).into()); } Ok(String::from_utf8(output.stdout).context(ErrorKind::ProcessExecution)?) } diff --git a/src/steps/generic.rs b/src/steps/generic.rs index b42475fa..71ac0da8 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -123,7 +123,7 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<() .and_then(PathExt::require)?; if !composer_home.is_descendant_of(base_dirs.home_dir()) { - Err(ErrorKind::SkipStep)?; + return Err(ErrorKind::SkipStep.into()); } print_separator("Composer"); @@ -149,9 +149,10 @@ pub fn run_remote_topgrade( #[cfg(unix)] { crate::tmux::run_remote_topgrade(hostname, &ssh)?; - Err(ErrorKind::SkipStep)? + Err(ErrorKind::SkipStep.into()) } + #[cfg(not(unix))] unreachable!("Tmux execution is only implemented in Unix"); } else { let mut args = vec!["-t", hostname]; diff --git a/src/steps/git.rs b/src/steps/git.rs index ca2b71a4..08f364fc 100644 --- a/src/steps/git.rs +++ b/src/steps/git.rs @@ -121,29 +121,28 @@ impl Git { if output.status.success() { let after_revision = get_head_revision(&cloned_git, &repo); - if before_revision != after_revision - && after_revision.is_some() - && before_revision.is_some() - { - println!("{} {}:", style("Changed").yellow().bold(), path); - Command::new(&cloned_git) - .current_dir(&repo) - .args(&[ - "--no-pager", - "log", - "--no-decorate", - "--oneline", - &format!("{}..{}", before_revision.unwrap(), after_revision.unwrap()), - ]) - .spawn() - .unwrap() - .wait() - .unwrap(); - println!(); - } else { - println!("{} {}", style("Up-to-date").green().bold(), path); + match (&before_revision, &after_revision) { + (Some(before), Some(after)) if before != after => { + println!("{} {}:", style("Changed").yellow().bold(), path); + Command::new(&cloned_git) + .current_dir(&repo) + .args(&[ + "--no-pager", + "log", + "--no-decorate", + "--oneline", + &format!("{}..{}", before, after), + ]) + .spawn() + .unwrap() + .wait() + .unwrap(); + println!(); + } + _ => { + println!("{} {}", style("Up-to-date").green().bold(), path); + } } - Ok(true) as Result } else { println!("{} pulling {}", style("Failed").red().bold(), path); diff --git a/src/steps/node.rs b/src/steps/node.rs index 254edc34..bb5adaf6 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -33,7 +33,7 @@ pub fn run_npm_upgrade(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Er let npm = require("npm").map(NPM::new)?; let npm_root = npm.root()?; if !npm_root.is_descendant_of(base_dirs.home_dir()) { - Err(ErrorKind::SkipStep)?; + return Err(ErrorKind::SkipStep.into()); } print_separator("Node Package Manager"); diff --git a/src/steps/vim.rs b/src/steps/vim.rs index 4790e94d..6ff321af 100644 --- a/src/steps/vim.rs +++ b/src/steps/vim.rs @@ -83,7 +83,7 @@ fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, ru if !status.success() { io::stdout().write(&output.stdout).ok(); io::stderr().write(&output.stderr).ok(); - Err(ErrorKind::ProcessFailed(status))? + return Err(ErrorKind::ProcessFailed(status).into()); } else { println!("Plugins upgraded") } @@ -98,7 +98,7 @@ pub fn upgrade_vim(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> let output = Command::new(&vim).arg("--version").check_output()?; if !output.starts_with("VIM") { - Err(ErrorKind::SkipStep)?; + return Err(ErrorKind::SkipStep.into()); } let vimrc = require_option(vimrc(&base_dirs))?; diff --git a/src/utils.rs b/src/utils.rs index af45b6ab..36c8fa3b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -16,7 +16,7 @@ impl Check for ExitStatus { if self.success() { Ok(()) } else { - Err(ErrorKind::ProcessFailed(self))? + Err(ErrorKind::ProcessFailed(self).into()) } } } @@ -55,7 +55,7 @@ impl PathExt for PathBuf { if self.exists() { Ok(self) } else { - Err(ErrorKind::SkipStep)? + Err(ErrorKind::SkipStep.into()) } } } @@ -182,7 +182,7 @@ pub fn require + Debug>(binary_name: T) -> Result match e.kind() { which_crate::ErrorKind::CannotFindBinaryPath => { debug!("Cannot find {:?}", &binary_name); - Err(ErrorKind::SkipStep)? + Err(ErrorKind::SkipStep.into()) } _ => { panic!("Detecting {:?} failed: {}", &binary_name, e); @@ -196,6 +196,6 @@ pub fn require_option(option: Option) -> Result { if let Some(value) = option { Ok(value) } else { - Err(ErrorKind::SkipStep)? + Err(ErrorKind::SkipStep.into()) } }