From aca2a3cf93d8888323ca6caf2ddb830fcea7e6a0 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 10 Nov 2023 09:56:18 +0900 Subject: [PATCH] tests: don't create new branch by "jj branch set" --- cli/tests/test_branch_command.rs | 56 +++++++++++++++------------- cli/tests/test_git_colocated.rs | 10 ++--- cli/tests/test_git_fetch.rs | 4 +- cli/tests/test_git_push.rs | 6 +-- cli/tests/test_git_remotes.rs | 2 +- cli/tests/test_log_command.rs | 2 +- cli/tests/test_next_prev_commands.rs | 2 +- 7 files changed, 44 insertions(+), 38 deletions(-) diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index 517339d2d..283a347ed 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -24,14 +24,25 @@ fn test_branch_multiple_names() { test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo", "bar"]); + insta::assert_snapshot!(stdout, @""); + insta::assert_snapshot!(stderr, @r###" + warning: Creating multiple branches: foo, bar + "###); + insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" + @ bar foo 230dd059e1b0 + ◉ 000000000000 + "###); + + test_env.jj_cmd_ok(&repo_path, &["new"]); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo", "bar"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" warning: Updating multiple branches: foo, bar "###); - insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - @ bar foo 230dd059e1b0 + @ bar foo 8bb159bc30a9 + ◉ 230dd059e1b0 ◉ 000000000000 "###); @@ -42,15 +53,10 @@ fn test_branch_multiple_names() { Deleted 2 branches. "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" - @ 230dd059e1b0 + @ 8bb159bc30a9 + ◉ 230dd059e1b0 ◉ 000000000000 "###); - - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo", "bar"]); - insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" - warning: Creating multiple branches: foo, bar - "###); } #[test] @@ -124,10 +130,10 @@ fn test_branch_forget_glob() { test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-1"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "bar-2"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-3"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-4"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-1"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar-2"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-3"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-4"]); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ bar-2 foo-1 foo-3 foo-4 230dd059e1b0 @@ -204,10 +210,10 @@ fn test_branch_delete_glob() { ); test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-1"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "bar-2"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-3"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo-4"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-1"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar-2"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-3"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo-4"]); // Push to create remote-tracking branches test_env.jj_cmd_ok(&repo_path, &["git", "push", "--all"]); @@ -298,7 +304,7 @@ fn test_branch_delete_export() { let repo_path = test_env.env_root().join("repo"); test_env.jj_cmd_ok(&repo_path, &["new"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo"]); test_env.jj_cmd_ok(&repo_path, &["git", "export"]); test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "foo"]); @@ -322,7 +328,7 @@ fn test_branch_forget_export() { let repo_path = test_env.env_root().join("repo"); test_env.jj_cmd_ok(&repo_path, &["new"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo"]); let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); insta::assert_snapshot!(stdout, @r###" foo: rlvkpnrz 65b6b74e (empty) (no description set) @@ -602,7 +608,7 @@ fn test_branch_track_untrack() { "###); // Track existing branch. Local branch should result in conflict. - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "feature2"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "feature2"]); test_env.jj_cmd_ok(&repo_path, &["branch", "track", "feature2@origin"]); insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" feature1: sptzoqmo 7b33f629 commit 1 @@ -738,7 +744,7 @@ fn test_branch_track_untrack_patterns() { insta::assert_snapshot!(stderr, @""); // Track local branch - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "main"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "main"]); insta::assert_snapshot!( test_env.jj_cmd_cli_error(&repo_path, &["branch", "track", "main"]), @r###" error: invalid value 'main' for '...': remote branch must be specified in branch@remote form @@ -844,7 +850,7 @@ fn test_branch_list() { "remote-delete", ] { test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", branch]); - test_env.jj_cmd_ok(&remote_path, &["branch", "set", branch]); + test_env.jj_cmd_ok(&remote_path, &["branch", "create", branch]); } test_env.jj_cmd_ok(&remote_path, &["new"]); test_env.jj_cmd_ok(&remote_path, &["git", "export"]); @@ -858,7 +864,7 @@ fn test_branch_list() { ); let local_path = test_env.env_root().join("local"); test_env.jj_cmd_ok(&local_path, &["new", "root()", "-m", "local-only"]); - test_env.jj_cmd_ok(&local_path, &["branch", "set", "local-only"]); + test_env.jj_cmd_ok(&local_path, &["branch", "create", "local-only"]); // Mutate refs in local repository test_env.jj_cmd_ok(&local_path, &["branch", "delete", "remote-delete"]); @@ -908,7 +914,7 @@ fn test_branch_list_filtered() { let remote_path = test_env.env_root().join("remote"); for branch in ["remote-keep", "remote-delete", "remote-rewrite"] { test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", branch]); - test_env.jj_cmd_ok(&remote_path, &["branch", "set", branch]); + test_env.jj_cmd_ok(&remote_path, &["branch", "create", branch]); } test_env.jj_cmd_ok(&remote_path, &["new"]); test_env.jj_cmd_ok(&remote_path, &["git", "export"]); @@ -922,7 +928,7 @@ fn test_branch_list_filtered() { ); let local_path = test_env.env_root().join("local"); test_env.jj_cmd_ok(&local_path, &["new", "root()", "-m", "local-keep"]); - test_env.jj_cmd_ok(&local_path, &["branch", "set", "local-keep"]); + test_env.jj_cmd_ok(&local_path, &["branch", "create", "local-keep"]); // Mutate refs in local repository test_env.jj_cmd_ok(&local_path, &["branch", "delete", "remote-delete"]); diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index c73c6a8bc..6d7244ad9 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -183,7 +183,7 @@ fn test_git_colocated_unborn_branch() { "###); // Assign the default branch. The branch is no longer "unborn". - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "-r@-", "master"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "-r@-", "master"]); // Stage some change, and check out root again. This should unset the HEAD. // https://github.com/martinvonz/jj/issues/1495 @@ -277,7 +277,7 @@ fn test_git_colocated_rebase_on_import() { std::fs::write(workspace_root.join("file"), "contents").unwrap(); test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "add a file"]); std::fs::write(workspace_root.join("file"), "modified").unwrap(); - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "master"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "master"]); test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "modify a file"]); // TODO: We shouldn't need this command here to trigger an import of the // refs/heads/master we just exported @@ -325,7 +325,7 @@ fn test_git_colocated_branches() { // Create a branch in jj. It should be exported to Git even though it points to // the working- copy commit. - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "master"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "master"]); insta::assert_snapshot!( git_repo.find_reference("refs/heads/master").unwrap().target().unwrap().to_string(), @"3560559274ab431feea00b7b7e0b9250ecce951f" @@ -371,7 +371,7 @@ fn test_git_colocated_branch_forget() { let _git_repo = git2::Repository::init(&workspace_root).unwrap(); test_env.jj_cmd_ok(&workspace_root, &["init", "--git-repo", "."]); test_env.jj_cmd_ok(&workspace_root, &["new"]); - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "foo"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "foo"]); insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###" @ 65b6b74e08973b88d38404430f119c8c79465250 foo ◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 HEAD@git @@ -525,7 +525,7 @@ fn test_git_colocated_external_checkout() { let git_repo = git2::Repository::init(&repo_path).unwrap(); test_env.jj_cmd_ok(&repo_path, &["init", "--git-repo=."]); test_env.jj_cmd_ok(&repo_path, &["ci", "-m=A"]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "-r@-", "master"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@-", "master"]); test_env.jj_cmd_ok(&repo_path, &["new", "-m=B", "root()"]); test_env.jj_cmd_ok(&repo_path, &["new"]); diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index 8263e68a4..7b97ff516 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -916,7 +916,7 @@ fn test_git_fetch_remove_fetch() { let repo_path = test_env.env_root().join("repo"); add_git_remote(&test_env, &repo_path, "origin"); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "origin"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "origin"]); insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" origin: qpvuntsm 230dd059 (empty) (no description set) "###); @@ -957,7 +957,7 @@ fn test_git_fetch_rename_fetch() { let repo_path = test_env.env_root().join("repo"); add_git_remote(&test_env, &repo_path, "origin"); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "origin"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "origin"]); insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" origin: qpvuntsm 230dd059 (empty) (no description set) "###); diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 688dfb356..e3ad26f25 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -239,7 +239,7 @@ fn test_git_push_locally_created_and_rewritten() { // Push locally-created branch test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-mlocal 1"]); - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "my"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my"]); let (_stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push"]); insta::assert_snapshot!(stderr, @r###" Branch changes to push to origin: @@ -567,7 +567,7 @@ fn test_git_push_conflict() { test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "second"]); std::fs::write(workspace_root.join("file"), "third").unwrap(); test_env.jj_cmd_ok(&workspace_root, &["rebase", "-r", "@", "-d", "@--"]); - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "my-branch"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]); test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "third"]); let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "--all"]); insta::assert_snapshot!(stderr, @r###" @@ -696,7 +696,7 @@ fn test_git_push_conflicting_branches() { .unwrap(); test_env.jj_cmd_ok(&workspace_root, &["git", "import"]); test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-m=description 3"]); - test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "branch2"]); + test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "branch2"]); test_env.jj_cmd_ok(&workspace_root, &["git", "fetch"]); insta::assert_snapshot!( test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]), @r###" diff --git a/cli/tests/test_git_remotes.rs b/cli/tests/test_git_remotes.rs index 42a16d87c..7d4993b56 100644 --- a/cli/tests/test_git_remotes.rs +++ b/cli/tests/test_git_remotes.rs @@ -140,7 +140,7 @@ fn test_git_remote_named_git() { .remote("git", "http://example.com/repo/repo") .unwrap(); test_env.jj_cmd_ok(&repo_path, &["init", "--git-repo=."]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "main"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "main"]); // The remote can be renamed. let (stdout, stderr) = diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 46a9e864d..ae66b395a 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -1059,7 +1059,7 @@ fn test_multiple_revsets() { let repo_path = test_env.env_root().join("repo"); for name in ["foo", "bar", "baz"] { test_env.jj_cmd_ok(&repo_path, &["new", "-m", name]); - test_env.jj_cmd_ok(&repo_path, &["branch", "set", name]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", name]); } // Default revset should be overridden if one or more -r options are specified. diff --git a/cli/tests/test_next_prev_commands.rs b/cli/tests/test_next_prev_commands.rs index 4a2e7606d..ec58196cf 100644 --- a/cli/tests/test_next_prev_commands.rs +++ b/cli/tests/test_next_prev_commands.rs @@ -123,7 +123,7 @@ fn test_next_fails_on_branching_children() { test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); // Create a main branch for this test - test_env.jj_cmd_ok(&repo_path, &["branch", "set", "main"]); + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "main"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);