From 811ac5ff23160621d68e2b1e2fde90eff6139b53 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 20 Nov 2023 14:25:40 -0800 Subject: [PATCH] cli new: have `--no-edit` print description of the new commit --- cli/src/commands/new.rs | 11 ++++++++--- cli/tests/test_new_command.rs | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index a90bd5811..b3f2713c6 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -199,12 +199,17 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.", } } num_rebased += tx.mut_repo().rebase_descendants(command.settings())?; + if args.no_edit { + write!(ui.stderr(), "Created new commit ")?; + tx.write_commit_summary(ui.stderr_formatter().as_mut(), &new_commit)?; + writeln!(ui.stderr())?; + } else { + tx.edit(&new_commit).unwrap(); + // The description of the new commit will be printed by tx.finish() + } if num_rebased > 0 { writeln!(ui.stderr(), "Rebased {num_rebased} descendant commits")?; } - if !args.no_edit { - tx.edit(&new_commit).unwrap(); - } tx.finish(ui)?; Ok(()) } diff --git a/cli/tests/test_new_command.rs b/cli/tests/test_new_command.rs index 9ae47a406..5a8f6b334 100644 --- a/cli/tests/test_new_command.rs +++ b/cli/tests/test_new_command.rs @@ -95,10 +95,10 @@ fn test_new_merge() { // Same test with `--no-edit` test_env.jj_cmd_ok(&repo_path, &["undo"]); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["new", "main", "@", "--no-edit"]); - // TODO(ilyagr): In this situation, `new` should probably report the identity of - // the newly created commit. insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @r###" + Created new commit znkkpsqq 200ed1a1 (empty) (no description set) + "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" ◉ 200ed1a14c8acf09783dafefe5bebf2ff58f12fd ├─╮