commands: Make all description_template call sites look the same

Just to make similar code look similar for easier
grepping/understanding.
This commit is contained in:
Manuel Mendez 2025-03-26 21:25:59 -04:00 committed by Manuel Mendez
parent 67128dd0ed
commit 32e841c444
5 changed files with 11 additions and 16 deletions

View File

@ -147,7 +147,8 @@ new working-copy commit.
let description = add_trailers(ui, &tx, &commit_builder)?;
commit_builder.set_description(description);
let temp_commit = commit_builder.write_hidden()?;
let description = description_template(ui, &tx, "", &temp_commit)?;
let intro = "";
let description = description_template(ui, &tx, intro, &temp_commit)?;
let description = edit_description(&text_editor, &description)?;
if description.is_empty() {
writedoc!(

View File

@ -205,7 +205,8 @@ pub(crate) fn cmd_describe(
.try_collect()?;
if let [(_, temp_commit)] = &*temp_commits {
let template = description_template(ui, &tx, "", temp_commit)?;
let intro = "";
let template = description_template(ui, &tx, intro, temp_commit)?;
let description = edit_description(&text_editor, &template)?;
commit_builders[0].set_description(description);
} else {

View File

@ -241,12 +241,8 @@ pub(crate) fn cmd_split(
let new_description = add_trailers(ui, &tx, &commit_builder)?;
commit_builder.set_description(new_description);
let temp_commit = commit_builder.write_hidden()?;
let template = description_template(
ui,
&tx,
"Enter a description for the selected changes.",
&temp_commit,
)?;
let intro = "Enter a description for the selected changes.";
let template = description_template(ui, &tx, intro, &temp_commit)?;
edit_description(&text_editor, &template)?
};
commit_builder.set_description(description);
@ -291,12 +287,8 @@ pub(crate) fn cmd_split(
let new_description = add_trailers(ui, &tx, &commit_builder)?;
commit_builder.set_description(new_description);
let temp_commit = commit_builder.write_hidden()?;
let template = description_template(
ui,
&tx,
"Enter a description for the remaining changes.",
&temp_commit,
)?;
let intro = "Enter a description for the remaining changes.";
let template = description_template(ui, &tx, intro, &temp_commit)?;
edit_description(&text_editor, &template)?
};
commit_builder.set_description(description);

View File

@ -202,7 +202,6 @@ pub(crate) fn cmd_squash(
add_trailers(ui, &tx, &commit_builder)?
}
} else {
let intro = "Enter a description for the combined commit.";
let combined = combine_messages_for_editing(
ui,
&tx,
@ -213,6 +212,7 @@ pub(crate) fn cmd_squash(
// It's weird that commit.description() contains "JJ: " lines, but works.
commit_builder.set_description(combined);
let temp_commit = commit_builder.write_hidden()?;
let intro = "Enter a description for the combined commit.";
let template = description_template(ui, &tx, intro, &temp_commit)?;
edit_description(&text_editor, &template)?
}

View File

@ -206,7 +206,8 @@ pub fn edit_multiple_descriptions(
bulk_message.push_str(&commit_hash);
bulk_message.push_str(" -------\n");
commits_map.insert(commit_hash, *commit_id);
let template = description_template(ui, tx, "", temp_commit)?;
let intro = "";
let template = description_template(ui, tx, intro, temp_commit)?;
bulk_message.push_str(&template);
append_blank_line(&mut bulk_message);
}