From 45d16f4b34147353bb315d629b309e92789df648 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 20 Jul 2024 17:18:01 +0900 Subject: [PATCH] cli: commit, split: set default description to intermediate commit object description_template_for_*() functions will be merged soon. We don't need to set the default description to the second commit of the split because its description should be kept empty if it was. --- cli/src/commands/commit.rs | 12 +++++------- cli/src/commands/split.rs | 5 +++-- cli/src/description_util.rs | 7 +------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index abbf800f6..fa1b80377 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -109,14 +109,12 @@ new working-copy commit. let description = if !args.message_paragraphs.is_empty() { join_message_paragraphs(&args.message_paragraphs) } else { + if commit_builder.description().is_empty() { + commit_builder.set_description(command.settings().default_description()); + } let temp_commit = commit_builder.write_hidden()?; - let template = description_template_for_commit( - ui, - command.settings(), - tx.base_workspace_helper(), - "", - &temp_commit, - )?; + let template = + description_template_for_commit(ui, tx.base_workspace_helper(), "", &temp_commit)?; edit_description(tx.base_repo(), &template, command.settings())? }; commit_builder.set_description(description); diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index 002cbe70c..3dda7051d 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -128,10 +128,12 @@ the operation will be aborted. .rewrite_commit(command.settings(), &commit) .detach(); commit_builder.set_tree_id(selected_tree_id); + if commit_builder.description().is_empty() { + commit_builder.set_description(command.settings().default_description()); + } let temp_commit = commit_builder.write_hidden()?; let template = description_template_for_commit( ui, - command.settings(), tx.base_workspace_helper(), "Enter a description for the first commit.", &temp_commit, @@ -175,7 +177,6 @@ the operation will be aborted. let temp_commit = commit_builder.write_hidden()?; let template = description_template_for_commit( ui, - command.settings(), tx.base_workspace_helper(), "Enter a description for the second commit.", &temp_commit, diff --git a/cli/src/description_util.rs b/cli/src/description_util.rs index c6f1b907c..b2ce716a5 100644 --- a/cli/src/description_util.rs +++ b/cli/src/description_util.rs @@ -112,7 +112,6 @@ pub fn description_template_for_describe( pub fn description_template_for_commit( ui: &Ui, - settings: &UserSettings, workspace_command: &WorkspaceCommandHelper, intro: &str, commit: &Commit, @@ -129,11 +128,7 @@ pub fn description_template_for_commit( if !intro.is_empty() { template_chunks.push(format!("JJ: {intro}\n")); } - template_chunks.push(if commit.description().is_empty() { - settings.default_description() - } else { - commit.description().to_owned() - }); + template_chunks.push(commit.description().to_owned()); if !diff_summary_bytes.is_empty() { template_chunks.push("\n".to_owned()); template_chunks.push(diff_summary_to_description(&diff_summary_bytes));