diff --git a/cli/tests/test_describe_command.rs b/cli/tests/test_describe_command.rs index 8b436bb1ea..98d3633538 100644 --- a/cli/tests/test_describe_command.rs +++ b/cli/tests/test_describe_command.rs @@ -265,6 +265,19 @@ fn test_describe_editor_env() { "); } +#[test] +fn test_describe_no_matching_revisions() { + 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(["describe", "none()"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + No revisions to describe. + [EOF] + "); +} + #[test] fn test_describe_multiple_commits() { let mut test_env = TestEnvironment::default(); diff --git a/cli/tests/test_metaedit_command.rs b/cli/tests/test_metaedit_command.rs index e716e7117c..165e8ffde3 100644 --- a/cli/tests/test_metaedit_command.rs +++ b/cli/tests/test_metaedit_command.rs @@ -95,7 +95,7 @@ fn test_metaedit() { [EOF] "); - // Update author + // Update author, ensure the commit can be specified with -r too work_dir.run_jj(["op", "restore", &setup_opid]).success(); work_dir .run_jj([ @@ -103,6 +103,7 @@ fn test_metaedit() { "--config=user.name=Ove Ridder", "--config=user.email=ove.ridder@example.com", "--update-author", + "-r", "kkmpptxzrspx", ]) .success(); @@ -410,6 +411,19 @@ fn test_metaedit() { "); } +#[test] +fn test_metaedit_no_matching_revisions() { + 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(["metaedit", "--update-change-id", "none()"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + No revisions to modify. + [EOF] + "); +} + #[test] fn test_metaedit_multiple_revisions() { let test_env = TestEnvironment::default(); @@ -645,7 +659,7 @@ fn test_metaedit_option_mutual_exclusion() { } #[test] -fn test_update_empty_author() { +fn test_update_empty_author_or_email() { let mut test_env = TestEnvironment::default(); // get rid of test author config @@ -666,25 +680,70 @@ fn test_update_empty_author() { [EOF] "); - // restore test author config + // restore test author config, exercise --quiet test_env.add_env_var("JJ_USER", "Test User"); test_env.add_env_var("JJ_EMAIL", "test.user@example.com"); let work_dir = test_env.work_dir("repo"); // update existing commit with restored test author config - insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author"]), @r" + insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author", "--quiet"]), @""); + insta::assert_snapshot!(work_dir.run_jj(["show"]), @r" + Commit ID: 0f13b5f2ea7fad147c133c81b87d31e7b1b8c564 + Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu + Author : Test User (2001-02-03 08:05:09) + Committer: Test User (2001-02-03 08:05:09) + + (no description set) + + [EOF] + "); + + // confirm user / email can be cleared/restored separately + // leave verbose to see no-email warning + hint + test_env.add_env_var("JJ_EMAIL", ""); + let work_dir = test_env.work_dir("repo"); + insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author"]), @r#" ------- stderr ------- Modified 1 commits: - qpvuntsm 0f13b5f2 (empty) (no description set) - Working copy (@) now at: qpvuntsm 0f13b5f2 (empty) (no description set) + qpvuntsm 234908d4 (empty) (no description set) + Working copy (@) now at: qpvuntsm 234908d4 (empty) (no description set) Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) + Warning: Email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. + Hint: To configure, run: + jj config set --user user.email "someone@example.com" + [EOF] + "#); + insta::assert_snapshot!(work_dir.run_jj(["show"]), @r" + Commit ID: 234908d4748ff3224a87888d8b52a4923e1a89a5 + Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu + Author : Test User <(no email set)> (2001-02-03 08:05:09) + Committer: Test User <(no email set)> (2001-02-03 08:05:11) + + (no description set) + [EOF] "); + + // confirm no-name warning + hint + test_env.add_env_var("JJ_USER", ""); + test_env.add_env_var("JJ_EMAIL", "test.user@example.com"); + let work_dir = test_env.work_dir("repo"); + insta::assert_snapshot!(work_dir.run_jj(["metaedit", "--update-author"]), @r#" + ------- stderr ------- + Modified 1 commits: + qpvuntsm ac5048cf (empty) (no description set) + Working copy (@) now at: qpvuntsm ac5048cf (empty) (no description set) + Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set) + Warning: Name not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. + Hint: To configure, run: + jj config set --user user.name "Some One" + [EOF] + "#); insta::assert_snapshot!(work_dir.run_jj(["show"]), @r" - Commit ID: 0f13b5f2ea7fad147c133c81b87d31e7b1b8c564 + Commit ID: ac5048cf35372ddc30e2590271781a3eab0bcaf8 Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu - Author : Test User (2001-02-03 08:05:09) - Committer: Test User (2001-02-03 08:05:09) + Author : (no name set) (2001-02-03 08:05:09) + Committer: (no name set) (2001-02-03 08:05:13) (no description set)