From fc84c02c8efcaafddea3dc29770929d964be6bde Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 17 Mar 2023 23:33:48 -0700 Subject: [PATCH] cli: add `jj describe --no-edit` to not open editor --- CHANGELOG.md | 3 ++- src/commands/mod.rs | 7 +++++++ tests/test_describe_command.rs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b14295f98..08d54ad7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 been moved from `jj debug` to `jj support`. * `jj describe` now supports `--reset-author` for resetting a commit's author - to the configured user. + to the configured user. `jj describe` also gained a `--no-edit` option to + avoid opening the editor. ### Fixed bugs diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 45e762016..66c818e7d 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -413,6 +413,11 @@ struct DescribeArgs { /// Read the change description from stdin #[arg(long)] stdin: bool, + /// Don't open an editor + /// + /// This is mainly useful in combination with e.g. `--reset-author`. + #[arg(long)] + no_edit: bool, /// Reset the author to the configured user /// /// This resets the author name, email, and timestamp. @@ -1807,6 +1812,8 @@ fn cmd_describe( buffer } else if let Some(message) = &args.message { message.into() + } else if args.no_edit { + commit.description().to_owned() } else { let template = description_template_for_commit(&workspace_command, &commit)?; edit_description(workspace_command.repo(), &template, command.settings())? diff --git a/tests/test_describe_command.rs b/tests/test_describe_command.rs index ce772acb3..a9e04b66e 100644 --- a/tests/test_describe_command.rs +++ b/tests/test_describe_command.rs @@ -177,7 +177,7 @@ fn test_describe_author() { "--config-toml", r#"user.name = "Ove Ridder" user.email = "ove.ridder@example.com""#, - "-m=description", + "--no-edit", "--reset-author", ], );