Skip to content

Commit

Permalink
Simplify should_update function
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 authored and mergify[bot] committed Sep 8, 2020
1 parent 187c915 commit 14a78d4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down Expand Up @@ -237,12 +233,12 @@ pub fn print_summary(plan: &TrimPlan, repo: &Repository) -> Result<()> {
Ok(())
}

fn should_update(git: &Git, interval: u64, explicit: bool) -> Result<bool> {
fn should_update(git: &Git, interval: u64, config_update: ConfigValue<bool>) -> Result<bool> {
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);
}
Expand Down

0 comments on commit 14a78d4

Please sign in to comment.