diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index fa1b80377..6202554b4 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -18,9 +18,7 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::command_error::{user_error, CommandError}; -use crate::description_util::{ - description_template_for_commit, edit_description, join_message_paragraphs, -}; +use crate::description_util::{description_template, edit_description, join_message_paragraphs}; use crate::ui::Ui; /// Update the description and create a new change on top. @@ -113,8 +111,7 @@ new working-copy commit. commit_builder.set_description(command.settings().default_description()); } let temp_commit = commit_builder.write_hidden()?; - let template = - description_template_for_commit(ui, tx.base_workspace_helper(), "", &temp_commit)?; + let template = description_template(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/describe.rs b/cli/src/commands/describe.rs index ff3cfe8c5..007fdf20d 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -19,9 +19,7 @@ use tracing::instrument; use crate::cli_util::{CommandHelper, RevisionArg}; use crate::command_error::CommandError; -use crate::description_util::{ - description_template_for_describe, edit_description, join_message_paragraphs, -}; +use crate::description_util::{description_template, edit_description, join_message_paragraphs}; use crate::ui::Ui; /// Update the change description or other metadata @@ -92,8 +90,7 @@ pub(crate) fn cmd_describe( commit_builder.set_description(command.settings().default_description()); } let temp_commit = commit_builder.write_hidden()?; - let template = - description_template_for_describe(ui, tx.base_workspace_helper(), &temp_commit)?; + let template = description_template(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 3dda7051d..f7c61d02a 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -19,7 +19,7 @@ use tracing::instrument; use crate::cli_util::{CommandHelper, RevisionArg}; use crate::command_error::{user_error_with_hint, CommandError}; -use crate::description_util::{description_template_for_commit, edit_description}; +use crate::description_util::{description_template, edit_description}; use crate::ui::Ui; /// Split a revision in two @@ -132,7 +132,7 @@ the operation will be aborted. commit_builder.set_description(command.settings().default_description()); } let temp_commit = commit_builder.write_hidden()?; - let template = description_template_for_commit( + let template = description_template( ui, tx.base_workspace_helper(), "Enter a description for the first commit.", @@ -175,7 +175,7 @@ the operation will be aborted. "".to_string() } else { let temp_commit = commit_builder.write_hidden()?; - let template = description_template_for_commit( + let template = description_template( ui, tx.base_workspace_helper(), "Enter a description for the second commit.", diff --git a/cli/src/description_util.rs b/cli/src/description_util.rs index b2ce716a5..f673c8c54 100644 --- a/cli/src/description_util.rs +++ b/cli/src/description_util.rs @@ -89,28 +89,7 @@ pub fn join_message_paragraphs(paragraphs: &[String]) -> String { .join("\n") } -pub fn description_template_for_describe( - ui: &Ui, - workspace_command: &WorkspaceCommandHelper, - commit: &Commit, -) -> Result { - let mut diff_summary_bytes = Vec::new(); - let diff_renderer = workspace_command.diff_renderer(vec![DiffFormat::Summary]); - diff_renderer.show_patch( - ui, - &mut PlainTextFormatter::new(&mut diff_summary_bytes), - commit, - &EverythingMatcher, - )?; - let description = commit.description().to_owned(); - if diff_summary_bytes.is_empty() { - Ok(description) - } else { - Ok(description + "\n" + &diff_summary_to_description(&diff_summary_bytes)) - } -} - -pub fn description_template_for_commit( +pub fn description_template( ui: &Ui, workspace_command: &WorkspaceCommandHelper, intro: &str,