// Copyright 2023 The Jujutsu Authors//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// https://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License. use indoc::indoc;use regex::Regex;use testutils::git; use crate::common::TestEnvironment; #[test]fn test_log_parents() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["new"]).success(); work_dir.run_jj(["new", "@-"]).success(); work_dir.run_jj(["new", "@", "@-"]).success(); let template = r#"commit_id ++ "\nP: " ++ parents.len() ++ " " ++ parents.map(|c| c.commit_id()) ++ "\n""#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @" @ 8b93ef7a3ceefa4e4b1a506945588dd0da2d9e3e ├─╮ P: 2 1c1c95df80e53b1e654608d7589f5baabb10ebb2 e8849ae12c709f2321908879bc724fdb2ab8a781 ○ │ 1c1c95df80e53b1e654608d7589f5baabb10ebb2 ├─╯ P: 1 e8849ae12c709f2321908879bc724fdb2ab8a781 ○ e8849ae12c709f2321908879bc724fdb2ab8a781 │ P: 1 0000000000000000000000000000000000000000 ◆ 0000000000000000000000000000000000000000 P: 0 [EOF] "); // List<Commit> can be filtered let template = r#""P: " ++ parents.filter(|c| !c.root()).map(|c| c.commit_id().short()) ++ "\n""#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @" @ P: 1c1c95df80e5 e8849ae12c70 ├─╮ ○ │ P: e8849ae12c70 ├─╯ ○ P: ◆ P: [EOF] "); let template = r#"parents.map(|c| c.commit_id().shortest(4))"#; let output = work_dir.run_jj(["log", "-T", template, "-r@", "--color=always"]); insta::assert_snapshot!(output, @" [1m[38;5;2m@[0m [1m[38;5;4m1[0m[38;5;8mc1c[39m [1m[38;5;4me[0m[38;5;8m884[39m │ ~ [EOF] "); // Commit object isn't printable let output = work_dir.run_jj(["log", "-T", "parents"]); insta::assert_snapshot!(output, @" ------- stderr ------- Error: Failed to parse template: Expected expression of type `Template`, but actual type is `List<Commit>` Caused by: --> 1:1 | 1 | parents | ^-----^ | = Expected expression of type `Template`, but actual type is `List<Commit>` [EOF] [exit status: 1] "); // Redundant argument passed to keyword method let template = r#"parents.map(|c| c.commit_id(""))"#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @r#" ------- stderr ------- Error: Failed to parse template: Function `commit_id`: Expected 0 arguments Caused by: --> 1:29 | 1 | parents.map(|c| c.commit_id("")) | ^^ | = Function `commit_id`: Expected 0 arguments [EOF] [exit status: 1] "#);} #[test]fn test_log_author_timestamp() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let output = work_dir.run_jj(["log", "-T", "author.timestamp()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 04:05:09.000 +07:00 ○ 2001-02-03 04:05:08.000 +07:00 ◆ 1970-01-01 00:00:00.000 +00:00 [EOF] ");} #[test]fn test_log_author_timestamp_ago() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let template = r#"author.timestamp().ago() ++ "\n""#; let output = work_dir .run_jj(&["log", "--no-graph", "-T", template]) .success(); let line_re = Regex::new(r"[0-9]+ years ago").unwrap(); assert!( output.stdout.raw().lines().all(|x| line_re.is_match(x)), "expected every line to match regex" );} #[test]fn test_log_author_timestamp_utc() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().utc()"]); insta::assert_snapshot!(output, @" @ 2001-02-02 21:05:07.000 +00:00 ◆ 1970-01-01 00:00:00.000 +00:00 [EOF] ");} #[cfg(unix)]#[test]fn test_log_author_timestamp_local() { let mut test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); test_env.add_env_var("TZ", "UTC-05:30"); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().local()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 08:05:07.000 +11:00 ◆ 1970-01-01 11:00:00.000 +11:00 [EOF] "); test_env.add_env_var("TZ", "UTC+10:00"); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().local()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 08:05:07.000 +11:00 ◆ 1970-01-01 11:00:00.000 +11:00 [EOF] ");} #[test]fn test_log_author_timestamp_after_before() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); let template = r#" separate(" ", author.timestamp(), ":", if(author.timestamp().after("1969"), "(after 1969)", "(before 1969)"), if(author.timestamp().before("1975"), "(before 1975)", "(after 1975)"), if(author.timestamp().before("now"), "(before now)", "(after now)") ) ++ "\n""#; let output = work_dir.run_jj(["log", "--no-graph", "-T", template]); insta::assert_snapshot!(output, @" 2001-02-03 04:05:08.000 +07:00 : (after 1969) (after 1975) (before now) 1970-01-01 00:00:00.000 +00:00 : (after 1969) (before 1975) (before now) [EOF] "); // Should display error with invalid date. let template = r#"author.timestamp().after("invalid date")"#; let output = work_dir.run_jj(["log", "-r@", "--no-graph", "-T", template]); insta::assert_snapshot!(output, @r#" ------- stderr ------- Error: Failed to parse template: Invalid date pattern Caused by: 1: --> 1:26 | 1 | author.timestamp().after("invalid date") | ^------------^ | = Invalid date pattern 2: expected unsupported identifier as position 0..7 [EOF] [exit status: 1] "#);} #[test]fn test_mine_is_true_when_author_is_user() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir .run_jj([ "--config=user.email=johndoe@example.com", "--config=user.name=John Doe", "new", ]) .success(); let output = work_dir.run_jj([ "log", "-T", r#"coalesce(if(mine, "mine"), author.email(), email_placeholder)"#, ]); insta::assert_snapshot!(output, @" @ johndoe@example.com ○ mine ◆ (no email set) [EOF] ");} #[test]fn test_log_json() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let output = work_dir.run_jj(["log", r#"-Tjson(self) ++ "\n""#]); insta::assert_snapshot!(output, @r#" @ {"commit_id":"b1cb6b2f9141e6ffee18532a8bf9a2075ca02606","parents":["68a505386f936fff6d718f55005e77ea72589bc1"],"change_id":"kkmpptxzrspxrzommnulwmwkkqwworpl","description":"second\n","author":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:09+07:00"},"committer":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:09+07:00"}} ○ {"commit_id":"68a505386f936fff6d718f55005e77ea72589bc1","parents":["0000000000000000000000000000000000000000"],"change_id":"qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu","description":"first\n","author":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:08+07:00"},"committer":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:08+07:00"}} ◆ {"commit_id":"0000000000000000000000000000000000000000","parents":[],"change_id":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","description":"","author":{"name":"","email":"","timestamp":"1970-01-01T00:00:00Z"},"committer":{"name":"","email":"","timestamp":"1970-01-01T00:00:00Z"}} [EOF] "#);} #[test]fn test_log_default() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.write_file("file1", "foo\n"); work_dir.run_jj(["describe", "-m", "add a file"]).success(); work_dir.run_jj(["new", "-m", "description 1"]).success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); // Test default log output format let output = work_dir.run_jj(["log"]); insta::assert_snapshot!(output, @" @ kkmpptxz test.user@example.com 2001-02-03 08:05:09 my-bookmark c938c088 │ (empty) description 1 ○ qpvuntsm test.user@example.com 2001-02-03 08:05:08 007859d3 │ add a file ◆ zzzzzzzz root() 00000000 [EOF] "); // Color let output = work_dir.run_jj(["log", "--color=always"]); insta::assert_snapshot!(output, @" [1m[38;5;2m@[0m [1m[38;5;13mk[38;5;8mkmpptxz[39m [38;5;3mtest.user@example.com[39m [38;5;14m2001-02-03 08:05:09[39m [38;5;13mmy-bookmark[39m [38;5;12mc[38;5;8m938c088[39m[0m │ [1m[38;5;10m(empty)[39m description 1[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4m007[0m[38;5;8m859d3[39m │ add a file [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m000[0m[38;5;8m00000[39m [EOF] "); // Color without graph let output = work_dir.run_jj(["log", "--color=always", "--no-graph"]); insta::assert_snapshot!(output, @" [1m[38;5;13mk[38;5;8mkmpptxz[39m [38;5;3mtest.user@example.com[39m [38;5;14m2001-02-03 08:05:09[39m [38;5;13mmy-bookmark[39m [38;5;12mc[38;5;8m938c088[39m[0m [1m[38;5;10m(empty)[39m description 1[0m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4m007[0m[38;5;8m859d3[39m add a file [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m000[0m[38;5;8m00000[39m [EOF] ");} #[test]fn test_log_default_without_working_copy() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["workspace", "forget"]).success(); let output = work_dir.run_jj(["log"]); insta::assert_snapshot!(output, @" ◆ zzzzzzzz root() 00000000 [EOF] ");} #[test]fn test_log_builtin_templates() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); // Render without graph to test line ending let render = |template| work_dir.run_jj(["log", "-T", template, "--no-graph"]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user@example.com 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user@example.com 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @" Commit ID: aec3ec964d0771edea9da48a2a170bc6ffa1c725 Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp Bookmarks: my-bookmark Author : (no name set) <(no email set)> (2001-02-03 08:05:08) Committer: (no name set) <(no email set)> (2001-02-03 08:05:08) (no description set) Commit ID: e8849ae12c709f2321908879bc724fdb2ab8a781 Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu Author : Test User <test.user@example.com> (2001-02-03 08:05:07) Committer: Test User <test.user@example.com> (2001-02-03 08:05:07) (no description set) Commit ID: 0000000000000000000000000000000000000000 Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Author : (no name set) <(no email set)> (1970-01-01 11:00:00) Committer: (no name set) <(no email set)> (1970-01-01 11:00:00) (no description set) [EOF] ");} #[test]fn test_log_builtin_templates_colored() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |template| work_dir.run_jj(["--color=always", "log", "-T", template]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m[0m │ [1m[38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m │ [38;5;2m(empty)[39m [38;5;2m(no description set)[39m [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m[0m │ [1m[38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m │ ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m │ [38;5;2m(empty)[39m [38;5;2m(no description set)[39m │ [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @" [1m[38;5;2m@[0m Commit ID: [38;5;4maec3ec964d0771edea9da48a2a170bc6ffa1c725[39m │ Change ID: [38;5;5mrlvkpnrzqnoowoytxnquwvuryrwnrmlp[39m │ Bookmarks: [38;5;5mmy-bookmark[39m │ Author : [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m2001-02-03 08:05:08[39m) │ Committer: [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m2001-02-03 08:05:08[39m) │ │ [38;5;2m (no description set)[39m │ ○ Commit ID: [38;5;4me8849ae12c709f2321908879bc724fdb2ab8a781[39m │ Change ID: [38;5;5mqpvuntsmwlqtpsluzzsnyyzlmlwvmlnu[39m │ Author : [38;5;3mTest User[39m <[38;5;3mtest.user@example.com[39m> ([38;5;6m2001-02-03 08:05:07[39m) │ Committer: [38;5;3mTest User[39m <[38;5;3mtest.user@example.com[39m> ([38;5;6m2001-02-03 08:05:07[39m) │ │ [38;5;2m (no description set)[39m │ [1m[38;5;14m◆[0m Commit ID: [38;5;4m0000000000000000000000000000000000000000[39m Change ID: [38;5;5mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz[39m Author : [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m1970-01-01 11:00:00[39m) Committer: [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m1970-01-01 11:00:00[39m) [38;5;2m (no description set)[39m [EOF] ");} #[test]fn test_log_builtin_templates_colored_debug() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |template| work_dir.run_jj(["--color=debug", "log", "-T", template]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>> [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable::>>[0m │ [1m[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>><<log commit mutable author email::@>><<log commit mutable author email domain::example.com>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable::>> │ [38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>> [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable::>>[0m │ [1m[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m │ <<log commit::>> <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>><<log commit mutable author email::@>><<log commit mutable author email domain::example.com>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable::>> │ [38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> │ <<log commit::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>>Lines 1–500 of 1894. Load more
// Copyright 2023 The Jujutsu Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use indoc::indoc; use regex::Regex; use testutils::git; use crate::common::TestEnvironment; #[test] fn test_log_parents() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["new"]).success(); work_dir.run_jj(["new", "@-"]).success(); work_dir.run_jj(["new", "@", "@-"]).success(); let template = r#"commit_id ++ "\nP: " ++ parents.len() ++ " " ++ parents.map(|c| c.commit_id()) ++ "\n""#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @" @ 8b93ef7a3ceefa4e4b1a506945588dd0da2d9e3e ├─╮ P: 2 1c1c95df80e53b1e654608d7589f5baabb10ebb2 e8849ae12c709f2321908879bc724fdb2ab8a781 ○ │ 1c1c95df80e53b1e654608d7589f5baabb10ebb2 ├─╯ P: 1 e8849ae12c709f2321908879bc724fdb2ab8a781 ○ e8849ae12c709f2321908879bc724fdb2ab8a781 │ P: 1 0000000000000000000000000000000000000000 ◆ 0000000000000000000000000000000000000000 P: 0 [EOF] "); // List<Commit> can be filtered let template = r#""P: " ++ parents.filter(|c| !c.root()).map(|c| c.commit_id().short()) ++ "\n""#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @" @ P: 1c1c95df80e5 e8849ae12c70 ├─╮ ○ │ P: e8849ae12c70 ├─╯ ○ P: ◆ P: [EOF] "); let template = r#"parents.map(|c| c.commit_id().shortest(4))"#; let output = work_dir.run_jj(["log", "-T", template, "-r@", "--color=always"]); insta::assert_snapshot!(output, @" [1m[38;5;2m@[0m [1m[38;5;4m1[0m[38;5;8mc1c[39m [1m[38;5;4me[0m[38;5;8m884[39m │ ~ [EOF] "); // Commit object isn't printable let output = work_dir.run_jj(["log", "-T", "parents"]); insta::assert_snapshot!(output, @" ------- stderr ------- Error: Failed to parse template: Expected expression of type `Template`, but actual type is `List<Commit>` Caused by: --> 1:1 | 1 | parents | ^-----^ | = Expected expression of type `Template`, but actual type is `List<Commit>` [EOF] [exit status: 1] "); // Redundant argument passed to keyword method let template = r#"parents.map(|c| c.commit_id(""))"#; let output = work_dir.run_jj(["log", "-T", template]); insta::assert_snapshot!(output, @r#" ------- stderr ------- Error: Failed to parse template: Function `commit_id`: Expected 0 arguments Caused by: --> 1:29 | 1 | parents.map(|c| c.commit_id("")) | ^^ | = Function `commit_id`: Expected 0 arguments [EOF] [exit status: 1] "#); } #[test] fn test_log_author_timestamp() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let output = work_dir.run_jj(["log", "-T", "author.timestamp()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 04:05:09.000 +07:00 ○ 2001-02-03 04:05:08.000 +07:00 ◆ 1970-01-01 00:00:00.000 +00:00 [EOF] "); } #[test] fn test_log_author_timestamp_ago() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let template = r#"author.timestamp().ago() ++ "\n""#; let output = work_dir .run_jj(&["log", "--no-graph", "-T", template]) .success(); let line_re = Regex::new(r"[0-9]+ years ago").unwrap(); assert!( output.stdout.raw().lines().all(|x| line_re.is_match(x)), "expected every line to match regex" ); } #[test] fn test_log_author_timestamp_utc() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().utc()"]); insta::assert_snapshot!(output, @" @ 2001-02-02 21:05:07.000 +00:00 ◆ 1970-01-01 00:00:00.000 +00:00 [EOF] "); } #[cfg(unix)] #[test] fn test_log_author_timestamp_local() { let mut test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); test_env.add_env_var("TZ", "UTC-05:30"); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().local()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 08:05:07.000 +11:00 ◆ 1970-01-01 11:00:00.000 +11:00 [EOF] "); test_env.add_env_var("TZ", "UTC+10:00"); let work_dir = test_env.work_dir("repo"); let output = work_dir.run_jj(["log", "-T", "author.timestamp().local()"]); insta::assert_snapshot!(output, @" @ 2001-02-03 08:05:07.000 +11:00 ◆ 1970-01-01 11:00:00.000 +11:00 [EOF] "); } #[test] fn test_log_author_timestamp_after_before() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); let template = r#" separate(" ", author.timestamp(), ":", if(author.timestamp().after("1969"), "(after 1969)", "(before 1969)"), if(author.timestamp().before("1975"), "(before 1975)", "(after 1975)"), if(author.timestamp().before("now"), "(before now)", "(after now)") ) ++ "\n""#; let output = work_dir.run_jj(["log", "--no-graph", "-T", template]); insta::assert_snapshot!(output, @" 2001-02-03 04:05:08.000 +07:00 : (after 1969) (after 1975) (before now) 1970-01-01 00:00:00.000 +00:00 : (after 1969) (before 1975) (before now) [EOF] "); // Should display error with invalid date. let template = r#"author.timestamp().after("invalid date")"#; let output = work_dir.run_jj(["log", "-r@", "--no-graph", "-T", template]); insta::assert_snapshot!(output, @r#" ------- stderr ------- Error: Failed to parse template: Invalid date pattern Caused by: 1: --> 1:26 | 1 | author.timestamp().after("invalid date") | ^------------^ | = Invalid date pattern 2: expected unsupported identifier as position 0..7 [EOF] [exit status: 1] "#); } #[test] fn test_mine_is_true_when_author_is_user() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir .run_jj([ "--config=user.email=johndoe@example.com", "--config=user.name=John Doe", "new", ]) .success(); let output = work_dir.run_jj([ "log", "-T", r#"coalesce(if(mine, "mine"), author.email(), email_placeholder)"#, ]); insta::assert_snapshot!(output, @" @ johndoe@example.com ○ mine ◆ (no email set) [EOF] "); } #[test] fn test_log_json() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["describe", "-m", "first"]).success(); work_dir.run_jj(["new", "-m", "second"]).success(); let output = work_dir.run_jj(["log", r#"-Tjson(self) ++ "\n""#]); insta::assert_snapshot!(output, @r#" @ {"commit_id":"b1cb6b2f9141e6ffee18532a8bf9a2075ca02606","parents":["68a505386f936fff6d718f55005e77ea72589bc1"],"change_id":"kkmpptxzrspxrzommnulwmwkkqwworpl","description":"second\n","author":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:09+07:00"},"committer":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:09+07:00"}} ○ {"commit_id":"68a505386f936fff6d718f55005e77ea72589bc1","parents":["0000000000000000000000000000000000000000"],"change_id":"qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu","description":"first\n","author":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:08+07:00"},"committer":{"name":"Test User","email":"test.user@example.com","timestamp":"2001-02-03T04:05:08+07:00"}} ◆ {"commit_id":"0000000000000000000000000000000000000000","parents":[],"change_id":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","description":"","author":{"name":"","email":"","timestamp":"1970-01-01T00:00:00Z"},"committer":{"name":"","email":"","timestamp":"1970-01-01T00:00:00Z"}} [EOF] "#); } #[test] fn test_log_default() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.write_file("file1", "foo\n"); work_dir.run_jj(["describe", "-m", "add a file"]).success(); work_dir.run_jj(["new", "-m", "description 1"]).success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); // Test default log output format let output = work_dir.run_jj(["log"]); insta::assert_snapshot!(output, @" @ kkmpptxz test.user@example.com 2001-02-03 08:05:09 my-bookmark c938c088 │ (empty) description 1 ○ qpvuntsm test.user@example.com 2001-02-03 08:05:08 007859d3 │ add a file ◆ zzzzzzzz root() 00000000 [EOF] "); // Color let output = work_dir.run_jj(["log", "--color=always"]); insta::assert_snapshot!(output, @" [1m[38;5;2m@[0m [1m[38;5;13mk[38;5;8mkmpptxz[39m [38;5;3mtest.user@example.com[39m [38;5;14m2001-02-03 08:05:09[39m [38;5;13mmy-bookmark[39m [38;5;12mc[38;5;8m938c088[39m[0m │ [1m[38;5;10m(empty)[39m description 1[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4m007[0m[38;5;8m859d3[39m │ add a file [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m000[0m[38;5;8m00000[39m [EOF] "); // Color without graph let output = work_dir.run_jj(["log", "--color=always", "--no-graph"]); insta::assert_snapshot!(output, @" [1m[38;5;13mk[38;5;8mkmpptxz[39m [38;5;3mtest.user@example.com[39m [38;5;14m2001-02-03 08:05:09[39m [38;5;13mmy-bookmark[39m [38;5;12mc[38;5;8m938c088[39m[0m [1m[38;5;10m(empty)[39m description 1[0m [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:08[39m [1m[38;5;4m007[0m[38;5;8m859d3[39m add a file [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m000[0m[38;5;8m00000[39m [EOF] "); } #[test] fn test_log_default_without_working_copy() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); work_dir.run_jj(["workspace", "forget"]).success(); let output = work_dir.run_jj(["log"]); insta::assert_snapshot!(output, @" ◆ zzzzzzzz root() 00000000 [EOF] "); } #[test] fn test_log_builtin_templates() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); // Render without graph to test line ending let render = |template| work_dir.run_jj(["log", "-T", template, "--no-graph"]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user@example.com 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark aec3ec96 (empty) (no description set) qpvuntsm test.user@example.com 2001-02-03 08:05:07 e8849ae1 (empty) (no description set) zzzzzzzz root() 00000000 [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @" Commit ID: aec3ec964d0771edea9da48a2a170bc6ffa1c725 Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp Bookmarks: my-bookmark Author : (no name set) <(no email set)> (2001-02-03 08:05:08) Committer: (no name set) <(no email set)> (2001-02-03 08:05:08) (no description set) Commit ID: e8849ae12c709f2321908879bc724fdb2ab8a781 Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu Author : Test User <test.user@example.com> (2001-02-03 08:05:07) Committer: Test User <test.user@example.com> (2001-02-03 08:05:07) (no description set) Commit ID: 0000000000000000000000000000000000000000 Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Author : (no name set) <(no email set)> (1970-01-01 11:00:00) Committer: (no name set) <(no email set)> (1970-01-01 11:00:00) (no description set) [EOF] "); } #[test] fn test_log_builtin_templates_colored() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |template| work_dir.run_jj(["--color=always", "log", "-T", template]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m [38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m [38;5;2m(empty)[39m [38;5;2m(no description set)[39m [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m[0m │ [1m[38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m │ [38;5;2m(empty)[39m [38;5;2m(no description set)[39m [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" [1m[38;5;2m@[0m [1m[38;5;13mr[38;5;8mlvkpnrz[39m [38;5;9m(no email set)[39m [38;5;14m2001-02-03 08:05:08[39m [38;5;13mmy-bookmark[39m [38;5;12ma[38;5;8mec3ec96[39m[0m │ [1m[38;5;10m(empty)[39m [38;5;10m(no description set)[39m[0m │ ○ [1m[38;5;5mq[0m[38;5;8mpvuntsm[39m [38;5;3mtest.user@example.com[39m [38;5;6m2001-02-03 08:05:07[39m [1m[38;5;4me[0m[38;5;8m8849ae1[39m │ [38;5;2m(empty)[39m [38;5;2m(no description set)[39m │ [1m[38;5;14m◆[0m [1m[38;5;5mz[0m[38;5;8mzzzzzzz[39m [38;5;2mroot()[39m [1m[38;5;4m0[0m[38;5;8m0000000[39m [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @" [1m[38;5;2m@[0m Commit ID: [38;5;4maec3ec964d0771edea9da48a2a170bc6ffa1c725[39m │ Change ID: [38;5;5mrlvkpnrzqnoowoytxnquwvuryrwnrmlp[39m │ Bookmarks: [38;5;5mmy-bookmark[39m │ Author : [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m2001-02-03 08:05:08[39m) │ Committer: [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m2001-02-03 08:05:08[39m) │ │ [38;5;2m (no description set)[39m │ ○ Commit ID: [38;5;4me8849ae12c709f2321908879bc724fdb2ab8a781[39m │ Change ID: [38;5;5mqpvuntsmwlqtpsluzzsnyyzlmlwvmlnu[39m │ Author : [38;5;3mTest User[39m <[38;5;3mtest.user@example.com[39m> ([38;5;6m2001-02-03 08:05:07[39m) │ Committer: [38;5;3mTest User[39m <[38;5;3mtest.user@example.com[39m> ([38;5;6m2001-02-03 08:05:07[39m) │ │ [38;5;2m (no description set)[39m │ [1m[38;5;14m◆[0m Commit ID: [38;5;4m0000000000000000000000000000000000000000[39m Change ID: [38;5;5mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz[39m Author : [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m1970-01-01 11:00:00[39m) Committer: [38;5;1m(no name set)[39m <[38;5;1m(no email set)[39m> ([38;5;6m1970-01-01 11:00:00[39m) [38;5;2m (no description set)[39m [EOF] "); } #[test] fn test_log_builtin_templates_colored_debug() { let test_env = TestEnvironment::default(); test_env.run_jj_in(".", ["git", "init", "repo"]).success(); let work_dir = test_env.work_dir("repo"); let render = |template| work_dir.run_jj(["--color=debug", "log", "-T", template]); work_dir .run_jj(["--config=user.email=''", "--config=user.name=''", "new"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "my-bookmark"]) .success(); insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>> [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_compact"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable::>>[0m │ [1m[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>><<log commit mutable author email::@>><<log commit mutable author email domain::example.com>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable::>> │ [38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>> [EOF] "); insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @" [1m[38;5;2m<<log commit node working_copy mutable::@>>[0m [1m[38;5;13m<<log commit working_copy mutable change_id shortest prefix::r>>[38;5;8m<<log commit working_copy mutable change_id shortest rest::lvkpnrz>>[39m<<log commit working_copy mutable:: >>[38;5;9m<<log commit working_copy mutable email placeholder::(no email set)>>[39m<<log commit working_copy mutable:: >>[38;5;14m<<log commit working_copy mutable committer timestamp local format::2001-02-03 08:05:08>>[39m<<log commit working_copy mutable:: >>[38;5;13m<<log commit working_copy mutable bookmarks name::my-bookmark>>[39m<<log commit working_copy mutable:: >>[38;5;12m<<log commit working_copy mutable commit_id shortest prefix::a>>[38;5;8m<<log commit working_copy mutable commit_id shortest rest::ec3ec96>>[39m<<log commit working_copy mutable::>>[0m │ [1m[38;5;10m<<log commit working_copy mutable empty::(empty)>>[39m<<log commit working_copy mutable:: >>[38;5;10m<<log commit working_copy mutable empty description placeholder::(no description set)>>[39m<<log commit working_copy mutable::>>[0m │ <<log commit::>> <<log commit node mutable::○>> [1m[38;5;5m<<log commit mutable change_id shortest prefix::q>>[0m[38;5;8m<<log commit mutable change_id shortest rest::pvuntsm>>[39m<<log commit mutable:: >>[38;5;3m<<log commit mutable author email local::test.user>><<log commit mutable author email::@>><<log commit mutable author email domain::example.com>>[39m<<log commit mutable:: >>[38;5;6m<<log commit mutable committer timestamp local format::2001-02-03 08:05:07>>[39m<<log commit mutable:: >>[1m[38;5;4m<<log commit mutable commit_id shortest prefix::e>>[0m[38;5;8m<<log commit mutable commit_id shortest rest::8849ae1>>[39m<<log commit mutable::>> │ [38;5;2m<<log commit mutable empty::(empty)>>[39m<<log commit mutable:: >>[38;5;2m<<log commit mutable empty description placeholder::(no description set)>>[39m<<log commit mutable::>> │ <<log commit::>> [1m[38;5;14m<<log commit node immutable::◆>>[0m [1m[38;5;5m<<log commit immutable change_id shortest prefix::z>>[0m[38;5;8m<<log commit immutable change_id shortest rest::zzzzzzz>>[39m<<log commit immutable:: >>[38;5;2m<<log commit immutable root::root()>>[39m<<log commit immutable:: >>[1m[38;5;4m<<log commit immutable commit_id shortest prefix::0>>[0m[38;5;8m<<log commit immutable commit_id shortest rest::0000000>>[39m<<log commit immutable::>>