Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the test_git_colocated_fetch_deleted_branch test #1599

Merged
merged 2 commits into from
May 11, 2023
Merged
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
42 changes: 23 additions & 19 deletions tests/test_git_colocated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn test_git_colocated() {
test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ 3e9369cd54227eb88455e1834dbc08aad6a16ac4
◉ e61b6729ff4292870702f2f72b2a60165679ef37 master
◉ e61b6729ff4292870702f2f72b2a60165679ef37 master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
insta::assert_snapshot!(
Expand All @@ -73,7 +73,7 @@ fn test_git_colocated() {
std::fs::write(workspace_root.join("file"), "modified").unwrap();
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ b26951a9c6f5c270e4d039880208952fd5faae5e
◉ e61b6729ff4292870702f2f72b2a60165679ef37 master
◉ e61b6729ff4292870702f2f72b2a60165679ef37 master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
insta::assert_snapshot!(
Expand All @@ -85,7 +85,7 @@ fn test_git_colocated() {
test_env.jj_cmd_success(&workspace_root, &["new"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ 9dbb23ff2ff5e66c43880f1042369d704f7a321e
◉ b26951a9c6f5c270e4d039880208952fd5faae5e
◉ b26951a9c6f5c270e4d039880208952fd5faae5e HEAD@git
◉ e61b6729ff4292870702f2f72b2a60165679ef37 master
◉ 0000000000000000000000000000000000000000
"###);
Expand Down Expand Up @@ -159,7 +159,7 @@ fn test_git_colocated_rebase_on_import() {
git_repo.set_head("refs/heads/master").unwrap();
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ 7f96185cfbe36341d0f9a86ebfaeab67a5922c7e
◉ 4bcbeaba9a4b309c5f45a8807fbf5499b9714315 master
◉ 4bcbeaba9a4b309c5f45a8807fbf5499b9714315 master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
}
Expand All @@ -176,7 +176,7 @@ fn test_git_colocated_branches() {
@ 3560559274ab431feea00b7b7e0b9250ecce951f
│ ◉ 1e6f0b403ed2ff9713b5d6b1dc601e4804250cda
├─╯
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 master
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);

Expand Down Expand Up @@ -207,7 +207,7 @@ fn test_git_colocated_branches() {
@ eb08b363bb5ef8ee549314260488980d7bbe8f63
│ ◉ 1e6f0b403ed2ff9713b5d6b1dc601e4804250cda master
├─╯
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
}
Expand Down Expand Up @@ -248,10 +248,12 @@ fn test_git_colocated_fetch_deleted_branch() {
let clone_path = test_env.env_root().join("clone");
git2::Repository::clone(origin_path.to_str().unwrap(), &clone_path).unwrap();
test_env.jj_cmd_success(&clone_path, &["init", "--git-repo=."]);
test_env.jj_cmd_success(&clone_path, &["new", "A"]);
insta::assert_snapshot!(get_log_output(&test_env, &clone_path), @r###"
@ bc7d08e8de9b7bc248b9358a05e96f1671bbd4d9
◉ e1f4268fabd2c84e880c5eb5bd87e076180fc8e3 B
◉ a86754f975f953fa25da4265764adc0c62e9ce6b A master
@ 1fa8b2e27c8c3da9764bda953dd81a06fb292d1a
│ ◉ e1f4268fabd2c84e880c5eb5bd87e076180fc8e3 B
├─╯
◉ a86754f975f953fa25da4265764adc0c62e9ce6b A master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);

Expand All @@ -260,9 +262,10 @@ fn test_git_colocated_fetch_deleted_branch() {
insta::assert_snapshot!(stdout, @"");
// TODO: e1f4 should have been abandoned (#864)
insta::assert_snapshot!(get_log_output(&test_env, &clone_path), @r###"
@ bc7d08e8de9b7bc248b9358a05e96f1671bbd4d9
◉ e1f4268fabd2c84e880c5eb5bd87e076180fc8e3
◉ a86754f975f953fa25da4265764adc0c62e9ce6b A master
@ 1fa8b2e27c8c3da9764bda953dd81a06fb292d1a
│ ◉ e1f4268fabd2c84e880c5eb5bd87e076180fc8e3
├─╯
◉ a86754f975f953fa25da4265764adc0c62e9ce6b A master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
}
Expand All @@ -280,7 +283,7 @@ fn test_git_colocated_external_checkout() {
// Checked out anonymous branch
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ 53637cd508ff02427dd78eca98f5b2450a6370ce
◉ 66f4d1806ae41bd604f69155dece64062a0056cf
◉ 66f4d1806ae41bd604f69155dece64062a0056cf HEAD@git
│ ◉ a86754f975f953fa25da4265764adc0c62e9ce6b master
├─╯
◉ 0000000000000000000000000000000000000000
Expand All @@ -302,7 +305,7 @@ fn test_git_colocated_external_checkout() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ 0521ce3b8c4e29aab79f3c750e2845dcbc4c3874
│ ◉ 66f4d1806ae41bd604f69155dece64062a0056cf
◉ │ a86754f975f953fa25da4265764adc0c62e9ce6b master
◉ │ a86754f975f953fa25da4265764adc0c62e9ce6b master HEAD@git
├─╯
◉ 0000000000000000000000000000000000000000
"###);
Expand All @@ -318,14 +321,14 @@ fn test_git_colocated_squash_undo() {
// Test the setup
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
@ rlvkpnrzqnoo 8f71e3b6a3be
◉ qpvuntsmwlqt a86754f975f9 A master
◉ qpvuntsmwlqt a86754f975f9 A master HEAD@git
◉ zzzzzzzzzzzz 000000000000
"###);

test_env.jj_cmd_success(&repo_path, &["squash"]);
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
@ zsuskulnrvyr f0c12b0396d9
◉ qpvuntsmwlqt 2f376ea1478c A master
◉ qpvuntsmwlqt 2f376ea1478c A master HEAD@git
◉ zzzzzzzzzzzz 000000000000
"###);
test_env.jj_cmd_success(&repo_path, &["undo"]);
Expand All @@ -334,7 +337,7 @@ fn test_git_colocated_squash_undo() {
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
◉ qpvuntsmwlqt 2f376ea1478c A master !divergence!
│ @ rlvkpnrzqnoo 8f71e3b6a3be
│ ◉ qpvuntsmwlqt a86754f975f9 A !divergence!
│ ◉ qpvuntsmwlqt a86754f975f9 A HEAD@git !divergence!
├─╯
◉ zzzzzzzzzzzz 000000000000
"###);
Expand All @@ -347,14 +350,15 @@ fn get_log_output_divergence(test_env: &TestEnvironment, repo_path: &Path) -> St
commit_id.short(),
description.first_line(),
branches,
git_head,
if(divergent, "!divergence!"),
)
"###;
test_env.jj_cmd_success(repo_path, &["log", "-T", template])
}

fn get_log_output(test_env: &TestEnvironment, workspace_root: &Path) -> String {
let template = r#"commit_id ++ " " ++ branches"#;
let template = r#"commit_id ++ " " ++ branches ++ " " ++ git_head"#;
test_env.jj_cmd_success(workspace_root, &["log", "-T", template, "-r=all()"])
}

Expand Down Expand Up @@ -415,7 +419,7 @@ fn test_git_colocated_unreachable_commits() {
test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ 66ae47cee4f8c28ee8d7e4f5d9401b03c07e22f2
◉ 2ee37513d2b5e549f7478c671a780053614bff19 master
◉ 2ee37513d2b5e549f7478c671a780053614bff19 master HEAD@git
◉ 0000000000000000000000000000000000000000
"###);
insta::assert_snapshot!(
Expand Down