Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply cargo clippy lints #108

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/commute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
15 changes: 6 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
Expand Down Expand Up @@ -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()?;
Expand Down Expand Up @@ -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(),
));
Expand Down Expand Up @@ -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`
Expand All @@ -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,
&current.hunk_to_apply,
&current.index_patch.old_path,
Expand Down Expand Up @@ -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");
Expand Down
Loading