cli new: have --no-edit print description of the new commit

This commit is contained in:
Ilya Grigoriev 2023-11-20 14:25:40 -08:00
parent e33f57a0f5
commit 811ac5ff23
2 changed files with 11 additions and 6 deletions

View file

@ -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(())
}

View file

@ -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