From d06c74f5b8cf960f27199e048320a4f68f77e937 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 1 Dec 2021 10:36:20 -0800 Subject: [PATCH] cli: add option to edit description while closing commit This lets you do `jj close -e` to edit the description even if it's already set (we normally bring up the editor only if the description is empty). --- src/commands.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 2f6709de2..cbe259623 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -819,6 +819,12 @@ With the `--from` and/or `--to` options, shows the difference from/to the given .default_value("@") .help("The revision to close"), ) + .arg( + Arg::with_name("edit") + .long("edit") + .short("e") + .help("Also edit the description"), + ) .arg(message_arg().help("The change description to use (don't open editor)")); let open_command = SubCommand::with_name("open") .about("Mark a revision open") @@ -2439,14 +2445,15 @@ fn cmd_close(ui: &mut Ui, command: &CommandHelper, args: &ArgMatches) -> Result< let repo = workspace_command.repo(); let mut commit_builder = CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit).set_open(false); - let description; - if args.is_present("message") { - description = args.value_of("message").unwrap().to_string(); + let description = if args.is_present("message") { + args.value_of("message").unwrap().to_string() } else if commit.description().is_empty() { - description = edit_description(repo, "\n\nJJ: Enter commit description.\n"); + edit_description(repo, "\n\nJJ: Enter commit description.\n") + } else if args.is_present("edit") { + edit_description(repo, commit.description()) } else { - description = commit.description().to_string(); - } + commit.description().to_string() + }; commit_builder = commit_builder.set_description(description); let mut tx = workspace_command.start_transaction(&format!("close commit {}", commit.id().hex()));