Skip to content

Commit

Permalink
rebase: add test showing unexpected commit abandoning
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnt4n committed Nov 8, 2024
1 parent b0eb776 commit 5b8e755
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions cli/tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,56 @@ fn test_rebase_skip_emptied() {
"###);
}

#[test]
fn test_rebase_skip_emptied_descendants() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");

create_commit(&test_env, &repo_path, "a", &[]);
create_commit(&test_env, &repo_path, "b", &["a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "-m", "c (will become empty)"]);
test_env.jj_cmd_ok(&repo_path, &["restore", "--from=b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "already empty"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "also already empty"]);

// Test the setup
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["log", "-T", "description"]), @r#"
@ also already empty
○ already empty
○ c (will become empty)
│ ○ b
├─╯
○ a
"#);

// TODO: Use `-r` instead of `-s` once `-r --skip-emptied` is supported.
let (stdout, stderr) = test_env.jj_cmd_ok(
&repo_path,
&["rebase", "-s", "b", "--before", "c", "--skip-emptied"],
);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Skipped rebase of 1 commits that were already in place
Rebased 2 descendant commits
Abandoned 1 newly emptied commits
Working copy now at: znkkpsqq 873ada86 (empty) also already empty
Parent commit : yostqsxw bfc5dad7 (empty) already empty
"#);

// TODO: Commits not in the rebase target set should not be abandoned even
// if they were emptied.
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["log", "-T", "description"]), @r#"
@ also already empty
○ already empty
○ b
○ a
"#);
}

#[test]
fn test_rebase_skip_if_on_destination() {
let test_env = TestEnvironment::default();
Expand Down

0 comments on commit 5b8e755

Please sign in to comment.