From 0b5dd5bf3615d448c267c6ff9f039bd1f4969bb5 Mon Sep 17 00:00:00 2001 From: Simon Wollwage Date: Fri, 29 Mar 2024 03:13:33 +0900 Subject: [PATCH] cli: allow branch list to combine -r and -a --- CHANGELOG.md | 2 ++ cli/src/commands/branch.rs | 2 +- cli/tests/test_branch_command.rs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a45ad9c24b..1b7f3aea80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj duplicate` and `jj abandon` can now take more than a single `-r` argument, for consistency with other commands. +* `jj branch list` now allows combining `-r` and `-a` options. + ### Fixed bugs ## [0.15.1] - 2024-03-06 diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 7417abd5ac..831dca35b8 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -98,7 +98,7 @@ pub struct BranchDeleteArgs { pub struct BranchListArgs { /// 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", "revisions", "tracked"])] + #[arg(long, short, conflicts_with_all = ["names", "tracked"])] all: bool, /// Show remote tracked branches only. Omits local Git-tracking branches by diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index decf83f0d8..a237b57ebc 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -1388,6 +1388,38 @@ fn test_branch_list_conflicted() { "###); } +#[test] +fn test_branch_list_revset_all() { + let test_env = TestEnvironment::default(); + test_env.add_config("git.auto-local-branch = true"); + + // Initialize remote refs + test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]); + let path = test_env.env_root().join("repo"); + for branch in [ + "branch-a", + "branch-b", + ] { + test_env.jj_cmd_ok(&path, &["new", "root()", "-m", branch]); + test_env.jj_cmd_ok(&path, &["branch", "create", branch]); + } + test_env.jj_cmd_ok(&path, &["git", "export"]); + + insta::assert_snapshot!( + test_env.jj_cmd_success(&path, &["branch", "list", "--all"]), @r###" + branch-a: rlvkpnrz 05e91824 (empty) branch-a + @git: rlvkpnrz 05e91824 (empty) branch-a + branch-b: zsuskuln 6dfacaa1 (empty) branch-b + @git: zsuskuln 6dfacaa1 (empty) branch-b + "###); + + insta::assert_snapshot!( + test_env.jj_cmd_success(&path, &["branch", "list", "--all", "-r", "description(branch-a)"]), @r###" + branch-a: rlvkpnrz 05e91824 (empty) branch-a + @git: rlvkpnrz 05e91824 (empty) branch-a + "###); +} + fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { let template = r#"branches ++ " " ++ commit_id.short()"#; test_env.jj_cmd_success(cwd, &["log", "-T", template])