Skip to content

Commit

Permalink
Update jj split tests to show what happens to branches
Browse files Browse the repository at this point in the history
When a commit is split, any branches pointing to it are moved to the second
commit created by the split. This is true even if the --siblings option is
used.


#3419
  • Loading branch information
emesterhazy committed Apr 2, 2024
1 parent 9763207 commit 21b59c8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cli/tests/test_split_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::path::Path;
use crate::common::TestEnvironment;

fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
let template = r#"separate(" ", change_id.short(), empty, description)"#;
let template = r#"separate(" ", change_id.short(), empty, description, local_branches)"#;
test_env.jj_cmd_success(cwd, &["log", "-T", template])
}

Expand Down Expand Up @@ -213,6 +213,11 @@ fn test_split_with_default_description() {

std::fs::write(workspace_path.join("file1"), "foo\n").unwrap();
std::fs::write(workspace_path.join("file2"), "bar\n").unwrap();

// Create a branch pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["branch", "create", "test_branch"]);

let edit_script = test_env.set_up_fake_editor();
std::fs::write(
edit_script,
Expand All @@ -239,7 +244,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed.
);
assert!(!test_env.env_root().join("editor2").exists());
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ rlvkpnrzqnoo false
@ kkmpptxzrspx false test_branch
◉ qpvuntsmwlqt false TESTED=TODO
◉ zzzzzzzzzzzz true
"###);
Expand All @@ -256,6 +261,15 @@ fn test_split_siblings_no_descendants() {

std::fs::write(workspace_path.join("file1"), "foo\n").unwrap();
std::fs::write(workspace_path.join("file2"), "bar\n").unwrap();

// Create a branch pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["branch", "create", "test_branch"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ qpvuntsmwlqt false test_branch
◉ zzzzzzzzzzzz true
"###);

let edit_script = test_env.set_up_fake_editor();
std::fs::write(
edit_script,
Expand All @@ -282,7 +296,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed.
);
assert!(!test_env.env_root().join("editor2").exists());
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ rlvkpnrzqnoo false
@ zsuskulnrvyr false test_branch
│ ◉ qpvuntsmwlqt false TESTED=TODO
├─╯
◉ zzzzzzzzzzzz true
Expand Down

0 comments on commit 21b59c8

Please sign in to comment.