diff options
author | Stephen Jung <tummychow511@gmail.com> | 2024-03-31 15:58:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-31 15:58:36 -0400 |
commit | a454f363587054c8369a40767a31b797696250ba (patch) | |
tree | ab259b1e7e14fee45f7c4da1868d3b69010a950e | |
parent | d2596815187df6d2f992362647539325640e50b2 (diff) | |
parent | b2cbe0732d9216280f3566702c0af9b9a8040ddf (diff) |
Merge pull request #108 from Pi-Cla/patch-1
Apply cargo clippy lints
-rw-r--r-- | src/commute.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 15 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/commute.rs b/src/commute.rs index 6009130..892a755 100644 --- a/src/commute.rs +++ b/src/commute.rs @@ -77,10 +77,8 @@ where // to be reverse line order (bottom to top), which also // happens to be reverse of the order they're stored .rev() - .fold(Some(after.clone()), |after, next| { - after - .and_then(|after| commute(next, &after)) - .map(|(commuted_after, _)| commuted_after) + .try_fold(after.clone(), |after, next| { + commute(next, &after).map(|(commuted_after, _)| commuted_after) }) } @@ -39,7 +39,7 @@ pub fn run(config: &mut Config) -> Result<()> { } fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { - let stack = stack::working_stack(&repo, config.base, config.force, config.logger)?; + let stack = stack::working_stack(repo, config.base, config.force, config.logger)?; if stack.is_empty() { crit!(config.logger, "No commits available to fix up, exiting"); return Ok(()); @@ -91,10 +91,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { } let summary_counts = stack::summary_counts(&stack); - ( - stack.into_iter().zip(diffs.into_iter()).collect(), - summary_counts, - ) + (stack.into_iter().zip(diffs).collect(), summary_counts) }; let mut head_tree = repo.head()?.peel_to_tree()?; @@ -188,7 +185,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { let mut commuted_old_path = old_path; let mut commuted_index_hunk = isolated_hunk; - 'commit: for &(ref commit, ref diff) in &stack { + 'commit: for (commit, diff) in &stack { let c_logger = config.logger.new(o!( "commit" => commit.id().to_string(), )); @@ -271,7 +268,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { } } - let target_always_sha: bool = config::fixup_target_always_sha(&repo); + let target_always_sha: bool = config::fixup_target_always_sha(repo); hunks_with_commit.sort_by_key(|h| h.dest_commit.id()); // * apply all hunks that are going to be fixed up into `dest_commit` @@ -286,7 +283,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { .zip(hunks_with_commit.iter().skip(1).map(Some).chain([None])) { let new_head_tree = apply_hunk_to_tree( - &repo, + repo, &head_tree, ¤t.hunk_to_apply, ¤t.index_patch.old_path, @@ -373,7 +370,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { assert!(number_of_parents <= 1); let mut command = Command::new("git"); - command.args(&["rebase", "--interactive", "--autosquash", "--autostash"]); + command.args(["rebase", "--interactive", "--autosquash", "--autostash"]); if number_of_parents == 0 { command.arg("--root"); |