Skip to content

Commit 48e1ec9

Browse files
committed
Deduplicate the select_commit/fixup logic
1 parent b9bef99 commit 48e1ec9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,13 @@ fn create_fixup_commit<'a>(
116116
let mut idx = repo.index()?;
117117
idx.update_all(&pathspecs, None)?;
118118
idx.write()?;
119-
let commit_to_amend =
120-
select_commit_to_amend(&repo, head_branch.upstream().ok(), max_commits)?;
121-
do_fixup_commit(&repo, &head_branch, &commit_to_amend, squash)?;
122-
Ok(commit_to_amend)
123119
} else {
124120
println!("Staged changes:");
125121
print_diff(Changes::Staged)?;
126-
let commit_to_amend =
127-
select_commit_to_amend(&repo, head_branch.upstream().ok(), max_commits)?;
128-
do_fixup_commit(&repo, &head_branch, &commit_to_amend, squash)?;
129-
Ok(commit_to_amend)
130122
}
123+
let commit_to_amend = select_commit_to_amend(&repo, head_branch.upstream().ok(), max_commits)?;
124+
do_fixup_commit(&repo, &head_branch, &commit_to_amend, squash)?;
125+
Ok(commit_to_amend)
131126
}
132127

133128
fn do_fixup_commit<'a>(

0 commit comments

Comments
 (0)