From e4ed623e6406c00468a1baf5a569b9a427408b32 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 20 Nov 2022 12:57:58 +0100 Subject: [PATCH] Skip hook if no globs are matched. --- hooked-cli/source/cli/run.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hooked-cli/source/cli/run.rs b/hooked-cli/source/cli/run.rs index 2f16239..2763312 100644 --- a/hooked-cli/source/cli/run.rs +++ b/hooked-cli/source/cli/run.rs @@ -53,15 +53,13 @@ pub fn hooked_run(config: Config, hook_type: String) -> Result<()> { .args(&["diff", "--name-only", "--cached"]) .capture()? .stdout_str(); - for line in staged_files.lines() { - if globs.is_match(line) { - println!( - "\t{} {}", - "≫".style(skipped_style), - hook_name.style(skipped_style) - ); - continue 'hook_loop; - } + if !staged_files.lines().any(|line| globs.is_match(line)) { + println!( + "\t{} {}", + "≫".style(skipped_style), + hook_name.style(skipped_style) + ); + continue 'hook_loop; } }