From 14a78d47a862dcce997e92c556520c78fbf2337d Mon Sep 17 00:00:00 2001 From: SeongChan Lee Date: Fri, 21 Aug 2020 15:08:21 +0900 Subject: [PATCH] Simplify should_update function --- src/main.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index e2b757d..2d4ee67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,11 +39,7 @@ fn main(args: Args) -> Result<()> { let mut checker = None; if *config.update { - if should_update( - &git, - *config.update_interval, - matches!(config.update, ConfigValue::Explicit { value: true , .. }), - )? { + if should_update(&git, *config.update_interval, config.update)? { checker = Some(remote_head_change_checker::RemoteHeadChangeChecker::spawn()?); remote_update(&git.repo, args.dry_run)?; println!(); @@ -237,12 +233,12 @@ pub fn print_summary(plan: &TrimPlan, repo: &Repository) -> Result<()> { Ok(()) } -fn should_update(git: &Git, interval: u64, explicit: bool) -> Result { +fn should_update(git: &Git, interval: u64, config_update: ConfigValue) -> Result { if interval == 0 { return Ok(true); } - if explicit { + if matches!(config_update, ConfigValue::Explicit { value: true , .. }) { trace!("explicitly set --update. force update"); return Ok(true); }