Skip to content

Commit

Permalink
cli new: have --no-edit print description of the new commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Nov 21, 2023
1 parent 1a31fe8 commit 80e1608
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
6 changes: 3 additions & 3 deletions cli/tests/test_new_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
├─╮
Expand Down

0 comments on commit 80e1608

Please sign in to comment.