cli: print operation summary before committing transaction

It seemed a bit odd that working-copy update was printed before the "undo"
operation we made earlier.
This commit is contained in:
Yuya Nishihara 2024-09-25 15:57:16 +09:00
parent 6cc76ba543
commit b30ce36c55
2 changed files with 4 additions and 5 deletions

View file

@ -68,14 +68,13 @@ pub fn cmd_op_undo(
&args.what,
);
tx.repo_mut().set_view(new_view);
tx.finish(ui, format!("undo operation {}", bad_op.id().hex()))?;
if let Some(mut formatter) = ui.status_formatter() {
write!(formatter, "Undid operation ")?;
let template = workspace_command.operation_summary_template();
template.format(&bad_op, &mut *formatter)?;
let template = tx.base_workspace_helper().operation_summary_template();
template.format(&bad_op, formatter.as_mut())?;
writeln!(formatter)?;
}
tx.finish(ui, format!("undo operation {}", bad_op.id().hex()))?;
Ok(())
}

View file

@ -757,9 +757,9 @@ fn test_git_colocated_undo_head_move() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Undid operation 951a1c249028 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 new empty commit
Working copy now at: royxmykx eb08b363 (empty) (no description set)
Parent commit : qpvuntsm 230dd059 (empty) (no description set)
Undid operation 951a1c249028 2001-02-03 04:05:13.000 +07:00 - 2001-02-03 04:05:13.000 +07:00 new empty commit
"#);
insta::assert_snapshot!(
git_repo.head().unwrap().target().unwrap().to_string(),