Make clippy happy

This commit is contained in:
Roey Darwish Dror
2019-09-28 15:13:01 +03:00
parent cfce9775df
commit e548cb4059
6 changed files with 32 additions and 32 deletions

View File

@@ -229,7 +229,7 @@ impl CommandExt for Command {
trace!("Output of {:?}: {:?}", self, output); trace!("Output of {:?}: {:?}", self, output);
let status = output.status; let status = output.status;
if !status.success() { if !status.success() {
Err(ErrorKind::ProcessFailed(status))? return Err(ErrorKind::ProcessFailed(status).into());
} }
Ok(String::from_utf8(output.stdout).context(ErrorKind::ProcessExecution)?) Ok(String::from_utf8(output.stdout).context(ErrorKind::ProcessExecution)?)
} }

View File

@@ -123,7 +123,7 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<()
.and_then(PathExt::require)?; .and_then(PathExt::require)?;
if !composer_home.is_descendant_of(base_dirs.home_dir()) { if !composer_home.is_descendant_of(base_dirs.home_dir()) {
Err(ErrorKind::SkipStep)?; return Err(ErrorKind::SkipStep.into());
} }
print_separator("Composer"); print_separator("Composer");
@@ -149,9 +149,10 @@ pub fn run_remote_topgrade(
#[cfg(unix)] #[cfg(unix)]
{ {
crate::tmux::run_remote_topgrade(hostname, &ssh)?; 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"); unreachable!("Tmux execution is only implemented in Unix");
} else { } else {
let mut args = vec!["-t", hostname]; let mut args = vec!["-t", hostname];

View File

@@ -121,29 +121,28 @@ impl Git {
if output.status.success() { if output.status.success() {
let after_revision = get_head_revision(&cloned_git, &repo); let after_revision = get_head_revision(&cloned_git, &repo);
if before_revision != after_revision match (&before_revision, &after_revision) {
&& after_revision.is_some() (Some(before), Some(after)) if before != after => {
&& before_revision.is_some() println!("{} {}:", style("Changed").yellow().bold(), path);
{ Command::new(&cloned_git)
println!("{} {}:", style("Changed").yellow().bold(), path); .current_dir(&repo)
Command::new(&cloned_git) .args(&[
.current_dir(&repo) "--no-pager",
.args(&[ "log",
"--no-pager", "--no-decorate",
"log", "--oneline",
"--no-decorate", &format!("{}..{}", before, after),
"--oneline", ])
&format!("{}..{}", before_revision.unwrap(), after_revision.unwrap()), .spawn()
]) .unwrap()
.spawn() .wait()
.unwrap() .unwrap();
.wait() println!();
.unwrap(); }
println!(); _ => {
} else { println!("{} {}", style("Up-to-date").green().bold(), path);
println!("{} {}", style("Up-to-date").green().bold(), path); }
} }
Ok(true) as Result<bool, Error> Ok(true) as Result<bool, Error>
} else { } else {
println!("{} pulling {}", style("Failed").red().bold(), path); println!("{} pulling {}", style("Failed").red().bold(), path);

View File

@@ -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 = require("npm").map(NPM::new)?;
let npm_root = npm.root()?; let npm_root = npm.root()?;
if !npm_root.is_descendant_of(base_dirs.home_dir()) { if !npm_root.is_descendant_of(base_dirs.home_dir()) {
Err(ErrorKind::SkipStep)?; return Err(ErrorKind::SkipStep.into());
} }
print_separator("Node Package Manager"); print_separator("Node Package Manager");

View File

@@ -83,7 +83,7 @@ fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, ru
if !status.success() { if !status.success() {
io::stdout().write(&output.stdout).ok(); io::stdout().write(&output.stdout).ok();
io::stderr().write(&output.stderr).ok(); io::stderr().write(&output.stderr).ok();
Err(ErrorKind::ProcessFailed(status))? return Err(ErrorKind::ProcessFailed(status).into());
} else { } else {
println!("Plugins upgraded") 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()?; let output = Command::new(&vim).arg("--version").check_output()?;
if !output.starts_with("VIM") { if !output.starts_with("VIM") {
Err(ErrorKind::SkipStep)?; return Err(ErrorKind::SkipStep.into());
} }
let vimrc = require_option(vimrc(&base_dirs))?; let vimrc = require_option(vimrc(&base_dirs))?;

View File

@@ -16,7 +16,7 @@ impl Check for ExitStatus {
if self.success() { if self.success() {
Ok(()) Ok(())
} else { } else {
Err(ErrorKind::ProcessFailed(self))? Err(ErrorKind::ProcessFailed(self).into())
} }
} }
} }
@@ -55,7 +55,7 @@ impl PathExt for PathBuf {
if self.exists() { if self.exists() {
Ok(self) Ok(self)
} else { } else {
Err(ErrorKind::SkipStep)? Err(ErrorKind::SkipStep.into())
} }
} }
} }
@@ -182,7 +182,7 @@ pub fn require<T: AsRef<OsStr> + Debug>(binary_name: T) -> Result<PathBuf, Error
Err(e) => match e.kind() { Err(e) => match e.kind() {
which_crate::ErrorKind::CannotFindBinaryPath => { which_crate::ErrorKind::CannotFindBinaryPath => {
debug!("Cannot find {:?}", &binary_name); debug!("Cannot find {:?}", &binary_name);
Err(ErrorKind::SkipStep)? Err(ErrorKind::SkipStep.into())
} }
_ => { _ => {
panic!("Detecting {:?} failed: {}", &binary_name, e); panic!("Detecting {:?} failed: {}", &binary_name, e);
@@ -196,6 +196,6 @@ pub fn require_option<T>(option: Option<T>) -> Result<T, Error> {
if let Some(value) = option { if let Some(value) = option {
Ok(value) Ok(value)
} else { } else {
Err(ErrorKind::SkipStep)? Err(ErrorKind::SkipStep.into())
} }
} }