From 8b8783d8ef3dbcfa831e27b81053538371749582 Mon Sep 17 00:00:00 2001 From: Simon Wollwage Date: Sun, 31 Mar 2024 18:54:11 +0900 Subject: [PATCH] cli: rename --all to --all-remotes for branch list --- CHANGELOG.md | 2 ++ cli/src/commands/branch.rs | 23 ++++++++++++++++++----- cli/tests/cli-reference@.md.snap | 6 +++++- cli/tests/test_branch_command.rs | 20 ++++++++++---------- cli/tests/test_git_clone.rs | 2 +- cli/tests/test_git_colocated.rs | 4 ++-- cli/tests/test_git_fetch.rs | 6 +++--- cli/tests/test_git_import_export.rs | 2 +- cli/tests/test_git_init.rs | 2 +- cli/tests/test_git_push.rs | 18 +++++++++--------- cli/tests/test_init_command.rs | 2 +- cli/tests/test_undo.rs | 2 +- 12 files changed, 54 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b7f3aea80..5d93e165f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj branch list` now allows combining `-r` and `-a` options. +* `--all` is now named `--all-remotes` for `jj branch list` + ### Fixed bugs ## [0.15.1] - 2024-03-06 diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 831dca35b8..44713e9f69 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -96,18 +96,24 @@ pub struct BranchDeleteArgs { /// https://github.com/martinvonz/jj/blob/main/docs/branches.md. #[derive(clap::Args, Clone, Debug)] pub struct BranchListArgs { + /// DEPRECATED: use `--all-remotes` instead. /// Show all tracking and non-tracking remote branches including the ones /// whose targets are synchronized with the local branches. - #[arg(long, short, conflicts_with_all = ["names", "tracked"])] + #[arg(long, conflicts_with_all = ["names", "tracked"], hide = true)] all: bool, + /// Show all tracking and non-tracking remote branches including the ones + /// whose targets are synchronized with the local branches. + #[arg(long, short, conflicts_with_all = ["names", "tracked"])] + all_remotes: bool, + /// Show remote tracked branches only. Omits local Git-tracking branches by /// default. - #[arg(long, short, conflicts_with_all = ["all"])] + #[arg(long, short, conflicts_with_all = ["all_remotes", "all"])] tracked: bool, /// Show conflicted branches only. - #[arg(long, short, conflicts_with_all = ["all"])] + #[arg(long, short, conflicts_with_all = ["all_remotes", "all"])] conflicted: bool, /// Show branches whose local name matches @@ -612,6 +618,13 @@ fn cmd_branch_list( let repo = workspace_command.repo(); let view = repo.view(); + if args.all { + writeln!( + ui.warning_default(), + "--all has been deprecated. Please use --all-remotes instead." + )?; + } + // Like cmd_git_push(), names and revisions are OR-ed. let branch_names_to_list = if !args.names.is_empty() || !args.revisions.is_empty() { let mut branch_names: HashSet<&str> = HashSet::new(); @@ -711,7 +724,7 @@ fn cmd_branch_list( for &(remote, remote_ref) in &tracking_remote_refs { let synced = remote_ref.target == *branch_target.local_target; - if !args.all && !args.tracked && synced { + if !(args.all || args.all_remotes || args.tracked) && synced { continue; } write!(formatter, " ")?; @@ -772,7 +785,7 @@ fn cmd_branch_list( } } - if args.all { + if args.all || args.all_remotes { for &(remote, remote_ref) in &untracked_remote_refs { write!(formatter.labeled("branch"), "{name}@{remote}")?; print_branch_target(formatter, &remote_ref.target)?; diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index dc7d797e9f..b1bd30adf8 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -297,7 +297,11 @@ For information about branches, see https://github.com/martinvonz/jj/blob/main/d ###### **Options:** -* `-a`, `--all` — Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches +* `--all` — DEPRECATED: use `--all-remotes` instead. Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches + + Possible values: `true`, `false` + +* `-a`, `--all-remotes` — Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches Possible values: `true`, `false` diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index 7400640851..aaf734c6bb 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -414,7 +414,7 @@ fn test_branch_delete_export() { test_env.jj_cmd_ok(&repo_path, &["git", "export"]); test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "foo"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" foo (deleted) @git: rlvkpnrz 65b6b74e (empty) (no description set) @@ -422,7 +422,7 @@ fn test_branch_delete_export() { "###); test_env.jj_cmd_ok(&repo_path, &["git", "export"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" "###); } @@ -435,7 +435,7 @@ fn test_branch_forget_export() { test_env.jj_cmd_ok(&repo_path, &["new"]); test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" foo: rlvkpnrz 65b6b74e (empty) (no description set) "###); @@ -449,7 +449,7 @@ fn test_branch_forget_export() { insta::assert_snapshot!(stderr, @""); // Forgetting a branch deletes local and remote-tracking branches including // the corresponding git-tracking branch. - let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @""); let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo", "--no-graph"]); insta::assert_snapshot!(stderr, @r###" @@ -463,7 +463,7 @@ fn test_branch_forget_export() { let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "export"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @""); - let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @""); } @@ -1021,7 +1021,7 @@ fn test_branch_list() { "###); insta::assert_snapshot!( - test_env.jj_cmd_success(&local_path, &["branch", "list", "--all"]), @r###" + test_env.jj_cmd_success(&local_path, &["branch", "list", "--all-remotes"]), @r###" local-only: wqnwkozp 4e887f78 (empty) local-only remote-delete (deleted) @origin: mnmymoky 203e60eb (empty) remote-delete @@ -1128,9 +1128,9 @@ fn test_branch_list_filtered() { @origin (ahead by 1 commits, behind by 1 commits): xyxluytn hidden 3e9a5af6 (empty) remote-rewrite "###); - // Select branches by name, combined with --all + // Select branches by name, combined with --all-remotes test_env.jj_cmd_ok(&local_path, &["git", "export"]); - insta::assert_snapshot!(query(&["--all", "-rbranches(remote-rewrite)"]), @r###" + insta::assert_snapshot!(query(&["--all-remotes", "-rbranches(remote-rewrite)"]), @r###" remote-rewrite: xyxluytn e31634b6 (empty) rewritten @git: xyxluytn e31634b6 (empty) rewritten @origin (ahead by 1 commits, behind by 1 commits): xyxluytn hidden 3e9a5af6 (empty) remote-rewrite @@ -1301,7 +1301,7 @@ fn test_branch_list_tracked() { ); insta::assert_snapshot!( - test_env.jj_cmd_success(&local_path, &["branch", "list", "--all"]), @r###" + test_env.jj_cmd_success(&local_path, &["branch", "list", "--all-remotes"]), @r###" local-only: nmzmmopx e1da745b (empty) local-only @git: nmzmmopx e1da745b (empty) local-only remote-delete (deleted) @@ -1402,5 +1402,5 @@ fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } diff --git a/cli/tests/test_git_clone.rs b/cli/tests/test_git_clone.rs index 1d4cee4abf..40f7d63384 100644 --- a/cli/tests/test_git_clone.rs +++ b/cli/tests/test_git_clone.rs @@ -365,5 +365,5 @@ fn test_git_clone_remote_default_branch() { } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } diff --git a/cli/tests/test_git_colocated.rs b/cli/tests/test_git_colocated.rs index b940fce3f8..1e4939bbd5 100644 --- a/cli/tests/test_git_colocated.rs +++ b/cli/tests/test_git_colocated.rs @@ -376,7 +376,7 @@ fn test_git_colocated_branch_forget() { ◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 HEAD@git ◉ 0000000000000000000000000000000000000000 "###); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" foo: rlvkpnrz 65b6b74e (empty) (no description set) @git: rlvkpnrz 65b6b74e (empty) (no description set) @@ -387,7 +387,7 @@ fn test_git_colocated_branch_forget() { insta::assert_snapshot!(stderr, @""); // A forgotten branch is deleted in the git repo. For a detailed demo explaining // this, see `test_branch_forget_export` in `test_branch_command.rs`. - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @""); } diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index 0ec1b3f581..fb63dd4c3f 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -50,7 +50,7 @@ fn add_git_remote(test_env: &TestEnvironment, repo_path: &Path, remote: &str) { } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, parents: &[&str]) { @@ -282,7 +282,7 @@ fn test_git_fetch_from_remote_named_git() { "###); // Implicit import shouldn't fail because of the remote ref. - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @""); @@ -296,7 +296,7 @@ fn test_git_fetch_from_remote_named_git() { // The remote can be renamed, and the ref can be imported. test_env.jj_cmd_ok(&repo_path, &["git", "remote", "rename", "git", "bar"]); - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" git: mrylzrtu 76fc7466 message @bar: mrylzrtu 76fc7466 message diff --git a/cli/tests/test_git_import_export.rs b/cli/tests/test_git_import_export.rs index 7e6b0be640..2871bef795 100644 --- a/cli/tests/test_git_import_export.rs +++ b/cli/tests/test_git_import_export.rs @@ -253,7 +253,7 @@ fn test_git_import_move_export_with_default_undo() { } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } fn get_git_repo_refs(git_repo: &git2::Repository) -> Vec<(String, CommitId)> { diff --git a/cli/tests/test_git_init.rs b/cli/tests/test_git_init.rs index 9223c6f6e9..485241f1f2 100644 --- a/cli/tests/test_git_init.rs +++ b/cli/tests/test_git_init.rs @@ -58,7 +58,7 @@ fn init_git_repo_with_opts( } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } fn read_git_target(workspace_root: &Path) -> String { diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 74419db64f..ad6f6161dd 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -50,7 +50,7 @@ fn set_up() -> (TestEnvironment, PathBuf) { fn test_git_push_nothing() { let (test_env, workspace_root) = set_up(); // Show the setup. `insta` has trouble if this is done inside `set_up()` - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: lzmmnrxq 45a3aa29 (empty) description 1 @origin: lzmmnrxq 45a3aa29 (empty) description 1 @@ -80,7 +80,7 @@ fn test_git_push_current_branch() { test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]); test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]); // Check the setup - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: lzmmnrxq 19e00bf6 (empty) modified branch1 commit @origin (ahead by 1 commits, behind by 1 commits): lzmmnrxq hidden 45a3aa29 (empty) description 1 @@ -104,7 +104,7 @@ fn test_git_push_current_branch() { Move branch branch2 from 8476341eb395 to 10ee3363b259 Add branch my-branch to 10ee3363b259 "###); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: lzmmnrxq 19e00bf6 (empty) modified branch1 commit @origin (ahead by 1 commits, behind by 1 commits): lzmmnrxq hidden 45a3aa29 (empty) description 1 @@ -256,7 +256,7 @@ fn test_git_push_locally_created_and_rewritten() { // Rewrite it and push again, which would fail if the pushed branch weren't // set to "tracking" test_env.jj_cmd_ok(&workspace_root, &["describe", "-mlocal 2"]); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: lzmmnrxq 45a3aa29 (empty) description 1 @origin: lzmmnrxq 45a3aa29 (empty) description 1 @@ -283,7 +283,7 @@ fn test_git_push_multiple() { test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]); test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]); // Check the setup - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1 (deleted) @origin: lzmmnrxq 45a3aa29 (empty) description 1 @@ -369,7 +369,7 @@ fn test_git_push_multiple() { Force branch branch2 from 8476341eb395 to 15dcdaa4f12f Add branch my-branch to 15dcdaa4f12f "###); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch2: yqosqzyt 15dcdaa4 (empty) foo @origin: yqosqzyt 15dcdaa4 (empty) foo @@ -757,7 +757,7 @@ fn test_git_push_conflicting_branches() { 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###" + test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]), @r###" branch1: lzmmnrxq 45a3aa29 (empty) description 1 @origin: lzmmnrxq 45a3aa29 (empty) description 1 branch2 (conflicted): @@ -837,7 +837,7 @@ fn test_git_push_tracked_vs_all() { test_env.jj_cmd_ok(&workspace_root, &["branch", "delete", "branch2"]); test_env.jj_cmd_ok(&workspace_root, &["branch", "untrack", "branch1@origin"]); test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "branch3"]); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: vruxwmqv a25f24af (empty) moved branch1 branch1@origin: lzmmnrxq 45a3aa29 (empty) description 1 @@ -859,7 +859,7 @@ fn test_git_push_tracked_vs_all() { // Untrack the last remaining tracked branch. test_env.jj_cmd_ok(&workspace_root, &["branch", "untrack", "branch2@origin"]); - let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]); + let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all-remotes"]); insta::assert_snapshot!(stdout, @r###" branch1: vruxwmqv a25f24af (empty) moved branch1 branch1@origin: lzmmnrxq 45a3aa29 (empty) description 1 diff --git a/cli/tests/test_init_command.rs b/cli/tests/test_init_command.rs index 403c4d14f1..c69d398bad 100644 --- a/cli/tests/test_init_command.rs +++ b/cli/tests/test_init_command.rs @@ -57,7 +57,7 @@ fn init_git_repo_with_opts( } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) } fn read_git_target(workspace_root: &Path) -> String { diff --git a/cli/tests/test_undo.rs b/cli/tests/test_undo.rs index 12e7b9a2be..47228fe183 100644 --- a/cli/tests/test_undo.rs +++ b/cli/tests/test_undo.rs @@ -388,5 +388,5 @@ fn test_branch_track_untrack_undo() { } fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String { - test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"]) + test_env.jj_cmd_success(repo_path, &["branch", "list", "--all-remotes"]) }