templates: Demo bug where operation summary is printed w/o color in `jj

undo`
This commit is contained in:
Ilya Grigoriev 2024-10-06 20:00:49 -07:00
parent 8bb806e7b6
commit f9d9c9c224

View file

@ -781,6 +781,70 @@ fn test_op_recover_from_bad_gc() {
"###);
}
#[test]
fn test_op_summary_diff_template() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
// Tests in color (easier to read with `less -R`)
test_env.jj_cmd_ok(&repo_path, &["new", "--no-edit", "-m=scratch"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=always"]);
insta::assert_snapshot!(&stdout, @"");
// BUG!! (Fixed in next commit)
insta::assert_snapshot!(&stderr, @r#"
Undid operation ac20a4ff4791 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit
"#);
let stdout = test_env.jj_cmd_success(
&repo_path,
&[
"op",
"diff",
"--from",
"0000000",
"--to",
"@",
"--color=always",
],
);
insta::assert_snapshot!(&stdout, @r#"
From operation 000000000000 root()
To operation e3792fce5b1f 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 undo operation ac20a4ff47914da9a2e43677b94455b86383bfb9227374d6531ecee85b9ff9230eeb96416a24bb27e7477aa18d50c01810e97c6a008b5c584224650846f4c05b
Changed commits:
Change qpvuntsmwlqt
+ qpvuntsm 230dd059 (empty) (no description set)
"#);
// Tests with templates
test_env.jj_cmd_ok(&repo_path, &["new", "--no-edit", "-m=scratch"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=debug"]);
insta::assert_snapshot!(&stdout, @"");
insta::assert_snapshot!(&stderr, @r#"
Undid operation <<id short::2301f6e6ec31>> <<time start::2001-02-03 04:05:11.000 +07:00>> - <<time end::2001-02-03 04:05:11.000 +07:00>> <<description first_line::new empty commit>>
"#);
let stdout = test_env.jj_cmd_success(
&repo_path,
&[
"op",
"diff",
"--from",
"0000000",
"--to",
"@",
"--color=debug",
],
);
insta::assert_snapshot!(&stdout, @r#"
<<op_log::From operation >><<op_log id short::000000000000>><<op_log:: >><<op_log root::root()>><<op_log::>>
<<op_log:: To operation >><<op_log id short::d208ae1b4e3c>><<op_log:: >><<op_log time start::2001-02-03 04:05:12.000 +07:00>><<op_log:: - >><<op_log time end::2001-02-03 04:05:12.000 +07:00>><<op_log:: >><<op_log description first_line::undo operation 2301f6e6ec31931a9b0a594742d6035a44c05250d1707f7f8678e888b11a98773ef07bf0e8008a5bccddf7114da4a35d1a1b1f7efa37c1e6c80d6bdb8f0d7a90>><<op_log::>>
Changed commits:
Change qpvuntsmwlqt
<<diff added::+>> <<change_id shortest prefix::q>><<change_id shortest rest::pvuntsm>> <<commit_id shortest prefix::2>><<commit_id shortest rest::30dd059>> <<empty::(empty)>> <<empty description placeholder::(no description set)>>
"#);
}
#[test]
fn test_op_diff() {
let test_env = TestEnvironment::default();