Skip to content
Open
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
37 changes: 37 additions & 0 deletions cli/tests/test_describe_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use indoc::indoc;
use crate::common::CommandOutput;
use crate::common::TestEnvironment;
use crate::common::TestWorkDir;
use crate::common::force_interactive;

#[test]
fn test_describe() {
Expand Down Expand Up @@ -265,6 +266,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();
Expand Down Expand Up @@ -610,6 +624,29 @@ fn test_multiple_message_args() {
");
}

#[test]
fn test_describe_stdin_description() {
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_with(|cmd| {
force_interactive(cmd)
.args(["describe", "--stdin"])
.write_stdin("first stdin\nsecond stdin")
});
insta::assert_snapshot!(output, @r#"
------- stderr -------
Working copy (@) now at: qpvuntsm 67a86922 (empty) first stdin
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set)
[EOF]
"#);
let output = work_dir.run_jj(["log", "--no-graph", "-r@", "-Tdescription"]);
insta::assert_snapshot!(output, @r"
first stdin
second stdin[EOF]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a bug. A description set by CLI should be terminated by newline.

");
}

#[test]
fn test_describe_default_description() {
let mut test_env = TestEnvironment::default();
Expand Down
77 changes: 68 additions & 9 deletions cli/tests/test_metaedit_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ 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([
"metaedit",
"--config=user.name=Ove Ridder",
"[email protected]",
"--update-author",
"-r",
"kkmpptxzrspx",
])
.success();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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", "[email protected]");
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 <[email protected]> (2001-02-03 08:05:09)
Committer: Test User <[email protected]> (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 "[email protected]"
[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", "[email protected]");
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 <[email protected]> (2001-02-03 08:05:09)
Committer: Test User <[email protected]> (2001-02-03 08:05:09)
Author : (no name set) <[email protected]> (2001-02-03 08:05:09)
Committer: (no name set) <[email protected]> (2001-02-03 08:05:13)

(no description set)

Expand Down