Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: add missing "\n" to builtin "root" output #3283

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ separate(" ",
label("root", "root()"),
format_short_commit_id(commit_id),
branches
)
) ++ "\n"
'''

'builtin_op_log_root(op_id)' = '''
separate(" ",
op_id.short(),
label("root", "root()"),
)
) ++ "\n"
'''


Expand Down
80 changes: 44 additions & 36 deletions cli/tests/test_commit_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ fn test_log_builtin_templates() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");
let render = |template| test_env.jj_cmd_success(&repo_path, &["log", "-T", template]);
// Render without graph and append "[EOF]" marker to test line ending
let render = |template| {
test_env.jj_cmd_success(&repo_path, &["log", "-T", template, "--no-graph"]) + "[EOF]\n"
};

test_env.jj_cmd_ok(
&repo_path,
Expand All @@ -204,52 +207,57 @@ fn test_log_builtin_templates() {
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "my-branch"]);

insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###"
@ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 (empty) (no description set)
◉ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set)
◉ zzzzzzzz root() 00000000
rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397 (empty) (no description set)
qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set)
zzzzzzzz root() 00000000
[EOF]
"###);

insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r###"
@ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397
│ (empty) (no description set)
◉ qpvuntsm [email protected] 2001-02-03 04:05:07.000 +07:00 230dd059
│ (empty) (no description set)
◉ zzzzzzzz root() 00000000
rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397
(empty) (no description set)
qpvuntsm [email protected] 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)
zzzzzzzz root() 00000000
[EOF]
"###);

insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r###"
@ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397
│ (empty) (no description set)
◉ qpvuntsm [email protected] 2001-02-03 04:05:07.000 +07:00 230dd059
│ (empty) (no description set)
◉ zzzzzzzz root() 00000000
rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 my-branch dc315397
(empty) (no description set)

qpvuntsm [email protected] 2001-02-03 04:05:07.000 +07:00 230dd059
(empty) (no description set)

zzzzzzzz root() 00000000

[EOF]
"###);

insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###"
@ Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74
Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp
Branches: my-branch
Author: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00)
Committer: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00)
(no description set)
Commit ID: 230dd059e1b059aefc0da06a2e5a7dbf22362f22
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
Author: Test User <[email protected]> (2001-02-03 04:05:07.000 +07:00)
Committer: Test User <[email protected]> (2001-02-03 04:05:07.000 +07:00)
(no description set)
Commit ID: 0000000000000000000000000000000000000000
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Author: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00)
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00)
Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74
Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp
Branches: my-branch
Author: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00)
Committer: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00)

(no description set)

Commit ID: 230dd059e1b059aefc0da06a2e5a7dbf22362f22
Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
Author: Test User <[email protected]> (2001-02-03 04:05:07.000 +07:00)
Committer: Test User <[email protected]> (2001-02-03 04:05:07.000 +07:00)

(no description set)

Commit ID: 0000000000000000000000000000000000000000
Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Author: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00)
Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00)

(no description set)
(no description set)

[EOF]
"###);
}

Expand Down
47 changes: 27 additions & 20 deletions cli/tests/test_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,32 +221,39 @@ fn test_op_log_builtin_templates() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");
let render = |template| test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template]);
// Render without graph and append "[EOF]" marker to test line ending
let render = |template| {
test_env.jj_cmd_success(&repo_path, &["op", "log", "-T", template, "--no-graph"])
+ "[EOF]\n"
};
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "description 0"]);

insta::assert_snapshot!(render(r#"builtin_op_log_compact"#), @r###"
@ 52ac15d375ba [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
│ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
│ args: jj describe -m 'description 0'
◉ b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
│ add workspace 'default'
◉ 9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
│ initialize repo
◉ 000000000000 root()
52ac15d375ba [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'description 0'
b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'
9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo
000000000000 root()
[EOF]
"###);

insta::assert_snapshot!(render(r#"builtin_op_log_comfortable"#), @r###"
@ 52ac15d375ba [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
│ describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
│ args: jj describe -m 'description 0'
◉ b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
│ add workspace 'default'
◉ 9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
│ initialize repo
◉ 000000000000 root()
52ac15d375ba [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
describe commit 230dd059e1b059aefc0da06a2e5a7dbf22362f22
args: jj describe -m 'description 0'

b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
add workspace 'default'

9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
initialize repo

000000000000 root()

[EOF]
"###);
}

Expand Down