-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: consider "JJ:" lines as comments also when not followed by space
We currently ignore lines prefixed with "JJ: " (including the space) in commit messages and in the list of sparse paths from `jj sparse edit`. I think I included the trailing space in the prefix simply because that's how we render comments line we insert before we ask the user to edit the file. However, as #5004 says, Git doesn't require a space after their "#" prefix. Neither does Mercurial after their "HG:" prefix. So let's follow their lead and not require the trailing space. Seems useful especially for people who have their editor configured to strip trailing spaces.
- Loading branch information
1 parent
94c6d6e
commit 043676a
Showing
9 changed files
with
37 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ fn test_commit_with_editor() { | |
std::fs::read_to_string(test_env.env_root().join("editor0")).unwrap(), @r###" | ||
initial | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Check that the editor content includes diff summary | ||
|
@@ -70,7 +70,7 @@ fn test_commit_with_editor() { | |
JJ: A file1 | ||
JJ: A file2 | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
} | ||
|
||
|
@@ -127,7 +127,7 @@ fn test_commit_interactive() { | |
JJ: This commit contains the following changes: | ||
JJ: A file1 | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Try again with --tool=<name>, which implies --interactive | ||
|
@@ -148,7 +148,7 @@ fn test_commit_interactive() { | |
JJ: This commit contains the following changes: | ||
JJ: A file1 | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
} | ||
|
||
|
@@ -172,15 +172,13 @@ fn test_commit_with_default_description() { | |
"###); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
TESTED=TODO | ||
JJ: This commit contains the following changes: | ||
JJ: A file1 | ||
JJ: A file2 | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
} | ||
|
||
|
@@ -221,14 +219,13 @@ fn test_commit_with_description_template() { | |
test_env.jj_cmd_ok(&workspace_path, &["commit", "file1"]); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
JJ: Author: Test User <[email protected]> (2001-02-03 08:05:08) | ||
JJ: Committer: Test User <[email protected]> (2001-02-03 08:05:08) | ||
JJ: file1 | 1 + | ||
JJ: 1 file changed, 1 insertion(+), 0 deletions(-) | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Only file2 with modified author should be included in the diff | ||
|
@@ -242,30 +239,28 @@ fn test_commit_with_description_template() { | |
], | ||
); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r#" | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
JJ: Author: Another User <[email protected]> (2001-02-03 08:05:08) | ||
JJ: Committer: Test User <[email protected]> (2001-02-03 08:05:09) | ||
JJ: file2 | 1 + | ||
JJ: 1 file changed, 1 insertion(+), 0 deletions(-) | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
"#); | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Timestamp after the reset should be available to the template | ||
test_env.jj_cmd_ok(&workspace_path, &["commit", "--reset-author"]); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r#" | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
JJ: Author: Test User <[email protected]> (2001-02-03 08:05:10) | ||
JJ: Committer: Test User <[email protected]> (2001-02-03 08:05:10) | ||
JJ: file3 | 1 + | ||
JJ: 1 file changed, 1 insertion(+), 0 deletions(-) | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
"#); | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
} | ||
|
||
#[test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ fn test_describe() { | |
std::fs::read_to_string(test_env.env_root().join("editor0")).unwrap(), @r###" | ||
description from CLI | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Set a description in editor | ||
|
@@ -475,15 +475,13 @@ fn test_describe_default_description() { | |
"###); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
TESTED=TODO | ||
JJ: This commit contains the following changes: | ||
JJ: A file1 | ||
JJ: A file2 | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
} | ||
|
||
|
@@ -566,15 +564,14 @@ fn test_describe_author() { | |
~ | ||
"#); | ||
insta::assert_snapshot!( | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r#" | ||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###" | ||
JJ: Author: Super Seeder <[email protected]> (2001-02-03 08:05:12) | ||
JJ: Committer: Test User <[email protected]> (2001-02-03 08:05:12) | ||
JJ: 0 files changed, 0 insertions(+), 0 deletions(-) | ||
JJ: Lines starting with "JJ: " (like this one) will be removed. | ||
"#); | ||
JJ: Lines starting with "JJ:" (like this one) will be removed. | ||
"###); | ||
|
||
// Change the author for multiple commits (the committer is always reset) | ||
test_env.jj_cmd_ok( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters