From 34270c860542323ff72d005ab018436474ccbfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 3 Jul 2022 16:45:51 +0200 Subject: [PATCH] refactor(clippy): apply clippy suggestions --- git-cliff-core/src/repo.rs | 56 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/git-cliff-core/src/repo.rs b/git-cliff-core/src/repo.rs index 347542ae75..159cc7585a 100644 --- a/git-cliff-core/src/repo.rs +++ b/git-cliff-core/src/repo.rs @@ -56,37 +56,33 @@ impl Repository { .filter_map(|id| self.inner.find_commit(id).ok()) .collect(); if include_path.is_some() || exclude_path.is_some() { - commits = commits - .into_iter() - .filter(|commit| { - if let Ok(prev_commit) = commit.parent(0) { - if let Ok(diff) = self.inner.diff_tree_to_tree( - commit.tree().ok().as_ref(), - prev_commit.tree().ok().as_ref(), - None, - ) { - return diff - .deltas() - .filter_map(|delta| delta.new_file().path()) - .any(|new_file_path| { - if let Some(include_path) = &include_path { - include_path.iter().any(|glob| { - glob.matches_path(new_file_path) - }) - } else if let Some(exclude_path) = &exclude_path - { - !exclude_path.iter().any(|glob| { - glob.matches_path(new_file_path) - }) - } else { - false - } - }); - } + commits.retain(|commit| { + if let Ok(prev_commit) = commit.parent(0) { + if let Ok(diff) = self.inner.diff_tree_to_tree( + commit.tree().ok().as_ref(), + prev_commit.tree().ok().as_ref(), + None, + ) { + return diff + .deltas() + .filter_map(|delta| delta.new_file().path()) + .any(|new_file_path| { + if let Some(include_path) = &include_path { + include_path + .iter() + .any(|glob| glob.matches_path(new_file_path)) + } else if let Some(exclude_path) = &exclude_path { + !exclude_path + .iter() + .any(|glob| glob.matches_path(new_file_path)) + } else { + false + } + }); } - false - }) - .collect() + } + false + }); } Ok(commits) }