Skip to content

Commit

Permalink
cli: commit, split: set default description to intermediate commit ob…
Browse files Browse the repository at this point in the history
…ject

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.
  • Loading branch information
yuja committed Jul 25, 2024
1 parent 6395d32 commit 45d16f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
12 changes: 5 additions & 7 deletions cli/src/commands/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions cli/src/description_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
Expand Down

0 comments on commit 45d16f4

Please sign in to comment.