mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-25 00:51:13 +00:00
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).
This commit is contained in:
parent
1f68de64d4
commit
d06c74f5b8
@ -819,6 +819,12 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
.default_value("@")
|
.default_value("@")
|
||||||
.help("The revision to close"),
|
.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)"));
|
.arg(message_arg().help("The change description to use (don't open editor)"));
|
||||||
let open_command = SubCommand::with_name("open")
|
let open_command = SubCommand::with_name("open")
|
||||||
.about("Mark a revision 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 repo = workspace_command.repo();
|
||||||
let mut commit_builder =
|
let mut commit_builder =
|
||||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit).set_open(false);
|
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit).set_open(false);
|
||||||
let description;
|
let description = if args.is_present("message") {
|
||||||
if args.is_present("message") {
|
args.value_of("message").unwrap().to_string()
|
||||||
description = args.value_of("message").unwrap().to_string();
|
|
||||||
} else if commit.description().is_empty() {
|
} 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 {
|
} else {
|
||||||
description = commit.description().to_string();
|
commit.description().to_string()
|
||||||
}
|
};
|
||||||
commit_builder = commit_builder.set_description(description);
|
commit_builder = commit_builder.set_description(description);
|
||||||
let mut tx =
|
let mut tx =
|
||||||
workspace_command.start_transaction(&format!("close commit {}", commit.id().hex()));
|
workspace_command.start_transaction(&format!("close commit {}", commit.id().hex()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user