Skip to content

Commit

Permalink
cli: remove author name from default annotate template, reorder fields
Browse files Browse the repository at this point in the history
The problem is that we don't have a padding function yet, so the output wasn't
aligned. I also don't like lengthy metadata that moves contents away from the
visible screen area.

This patch also reorders fields to match the log output. I don't have a strong
opinion about that.
  • Loading branch information
yuja committed Oct 16, 2024
1 parent b6f9b1b commit 6332562
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ commit_summary = 'format_commit_summary_with_refs(self, bookmarks)'
annotate_commit_summary = '''
separate(" ",
format_short_id(change_id),
format_short_id(commit_id),
format_short_signature(author),
format_timestamp(committer.timestamp()),
format_short_id(commit_id),
)
'''

Expand Down
44 changes: 22 additions & 22 deletions cli/tests/test_file_annotate_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ fn test_annotate_linear() {
append_to_file(&repo_path.join("file.txt"), "new text from new commit");

let stdout = test_env.jj_cmd_success(&repo_path, &["file", "annotate", "file.txt"]);
insta::assert_snapshot!(stdout, @r###"
qpvuntsm 8934c772 [email protected] 2001-02-03 08:05:08 1: line1
kkmpptxz 41ae16e6 [email protected] 2001-02-03 08:05:10 2: new text from new commit
"###);
insta::assert_snapshot!(stdout, @r#"
qpvuntsm 2001-02-03 08:05:08 8934c772 1: line1
kkmpptxz 2001-02-03 08:05:10 41ae16e6 2: new text from new commit
"#);
}

#[test]
Expand Down Expand Up @@ -72,11 +72,11 @@ fn test_annotate_merge() {
.unwrap();

let stdout = test_env.jj_cmd_success(&repo_path, &["file", "annotate", "file.txt"]);
insta::assert_snapshot!(stdout, @r###"
qpvuntsm 8934c772 [email protected] 2001-02-03 08:05:08 1: line1
zsuskuln 712ba14a [email protected] 2001-02-03 08:05:11 2: new text from new commit 1
royxmykx b0571bd9 [email protected] 2001-02-03 08:05:13 3: new text from new commit 2
"###);
insta::assert_snapshot!(stdout, @r#"
qpvuntsm 2001-02-03 08:05:08 8934c772 1: line1
zsuskuln 2001-02-03 08:05:11 712ba14a 2: new text from new commit 1
royxmykx 2001-02-03 08:05:13 b0571bd9 3: new text from new commit 2
"#);
}

#[test]
Expand All @@ -102,15 +102,15 @@ fn test_annotate_conflicted() {
test_env.jj_cmd_ok(&repo_path, &["new"]);

let stdout = test_env.jj_cmd_success(&repo_path, &["file", "annotate", "file.txt"]);
insta::assert_snapshot!(stdout, @r###"
qpvuntsm 8934c772 [email protected] 2001-02-03 08:05:08 1: line1
yostqsxw 7b90c9f6 [email protected] 2001-02-03 08:05:15 2: <<<<<<< Conflict 1 of 1
yostqsxw 7b90c9f6 [email protected] 2001-02-03 08:05:15 3: %%%%%%% Changes from base to side #1
yostqsxw 7b90c9f6 [email protected] 2001-02-03 08:05:15 4: +new text from new commit 1
yostqsxw 7b90c9f6 [email protected] 2001-02-03 08:05:15 5: +++++++ Contents of side #2
royxmykx b0571bd9 [email protected] 2001-02-03 08:05:13 6: new text from new commit 2
yostqsxw 7b90c9f6 [email protected] 2001-02-03 08:05:15 7: >>>>>>> Conflict 1 of 1 ends
"###);
insta::assert_snapshot!(stdout, @r##"
qpvuntsm 2001-02-03 08:05:08 8934c772 1: line1
yostqsxw 2001-02-03 08:05:15 7b90c9f6 2: <<<<<<< Conflict 1 of 1
yostqsxw 2001-02-03 08:05:15 7b90c9f6 3: %%%%%%% Changes from base to side #1
yostqsxw 2001-02-03 08:05:15 7b90c9f6 4: +new text from new commit 1
yostqsxw 2001-02-03 08:05:15 7b90c9f6 5: +++++++ Contents of side #2
royxmykx 2001-02-03 08:05:13 b0571bd9 6: new text from new commit 2
yostqsxw 2001-02-03 08:05:15 7b90c9f6 7: >>>>>>> Conflict 1 of 1 ends
"##);
}

#[test]
Expand Down Expand Up @@ -141,8 +141,8 @@ fn test_annotate_merge_one_sided_conflict_resolution() {
.unwrap();

let stdout = test_env.jj_cmd_success(&repo_path, &["file", "annotate", "file.txt"]);
insta::assert_snapshot!(stdout, @r###"
qpvuntsm 8934c772 [email protected] 2001-02-03 08:05:08 1: line1
zsuskuln 712ba14a [email protected] 2001-02-03 08:05:11 2: new text from new commit 1
"###);
insta::assert_snapshot!(stdout, @r#"
qpvuntsm 2001-02-03 08:05:08 8934c772 1: line1
zsuskuln 2001-02-03 08:05:11 712ba14a 2: new text from new commit 1
"#);
}

0 comments on commit 6332562

Please sign in to comment.