diff --git a/CHANGELOG.md b/CHANGELOG.md index 17e69fffec..b030545ec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,7 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 revsets now support glob matching. * `jj branch delete`/`forget` now support [string pattern - syntax](docs/revsets.md#string-patterns). + syntax](docs/revsets.md#string-patterns). The `--glob` option is deprecated in + favor of `glob:` pattern. ### Fixed bugs diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 14b68888c7..0e5349d64f 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -62,8 +62,8 @@ pub struct BranchDeleteArgs { #[arg(required_unless_present_any(&["glob"]), value_parser = parse_name_pattern)] pub names: Vec, - /// A glob pattern indicating branches to delete. - #[arg(long, value_parser = StringPattern::glob)] + /// Deprecated. Please prefix the pattern with `glob:` instead. + #[arg(long, hide = true, value_parser = StringPattern::glob)] pub glob: Vec, } @@ -107,8 +107,8 @@ pub struct BranchForgetArgs { #[arg(required_unless_present_any(&["glob"]), value_parser = parse_name_pattern)] pub names: Vec, - /// A glob pattern indicating branches to forget. - #[arg(long, value_parser = StringPattern::glob)] + /// Deprecated. Please prefix the pattern with `glob:` instead. + #[arg(long, hide = true, value_parser = StringPattern::glob)] pub glob: Vec, } @@ -347,6 +347,12 @@ fn cmd_branch_delete( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let view = workspace_command.repo().view(); + if !args.glob.is_empty() { + writeln!( + ui.warning(), + "--glob has been deprecated. Please prefix the pattern with `glob:` instead." + )?; + } let name_patterns = [&args.names[..], &args.glob[..]].concat(); let names = find_local_branches(view, &name_patterns)?; let mut tx = @@ -369,6 +375,12 @@ fn cmd_branch_forget( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let view = workspace_command.repo().view(); + if !args.glob.is_empty() { + writeln!( + ui.warning(), + "--glob has been deprecated. Please prefix the pattern with `glob:` instead." + )?; + } let name_patterns = [&args.names[..], &args.glob[..]].concat(); let names = find_forgettable_branches(view, &name_patterns)?; let mut tx = diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index 312ed340bc..7b1f3693fe 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -99,6 +99,7 @@ fn test_branch_forget_glob() { test_env.jj_cmd_ok(&repo_path, &["branch", "forget", "--glob", "foo-[1-3]"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. Forgot 2 branches. "###); test_env.jj_cmd_ok(&repo_path, &["undo"]); @@ -119,7 +120,9 @@ fn test_branch_forget_glob() { &["branch", "forget", "foo-4", "--glob", "foo-*", "glob:foo-*"], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. + "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ bar-2 230dd059e1b0 ◉ 000000000000 @@ -139,6 +142,7 @@ fn test_branch_forget_glob() { &["branch", "forget", "glob:bar*", "glob:baz*", "--glob=boom*"], ); insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. Error: No matching branches for patterns: baz*, boom* "###); } @@ -177,6 +181,7 @@ fn test_branch_delete_glob() { test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "--glob", "foo-[1-3]"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. Deleted 2 branches. "###); test_env.jj_cmd_ok(&repo_path, &["undo"]); @@ -194,6 +199,7 @@ fn test_branch_delete_glob() { // forget`, it's not allowed to delete already deleted branches. let stderr = test_env.jj_cmd_failure(&repo_path, &["branch", "delete", "--glob=foo-[1-3]"]); insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. Error: No matching branches for patterns: foo-[1-3] "###); @@ -204,7 +210,9 @@ fn test_branch_delete_glob() { &["branch", "delete", "foo-4", "--glob", "foo-*", "glob:foo-*"], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @r###" + --glob has been deprecated. Please prefix the pattern with `glob:` instead. + "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ bar-2 foo-1@origin foo-3@origin foo-4@origin 6fbf398c2d59 ◉ 000000000000