From ddeb10b3f32d2590cfea0c6da33cb44751fbf719 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 20 Jun 2024 20:20:01 +0900 Subject: [PATCH] cli: branch: drop support for deprecated --glob option It's been 8 months since the option got deprecated by 8dbe12da2a6d. --- CHANGELOG.md | 2 ++ cli/src/commands/branch/delete.rs | 15 ++------------- cli/src/commands/branch/forget.rs | 15 ++------------- cli/tests/cli-reference@.md.snap | 4 ++-- cli/tests/test_branch_command.rs | 32 +++++++++++-------------------- cli/tests/test_git_fetch.rs | 2 +- 6 files changed, 20 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adf7c2b4c1..134613f38b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj fix` now defaults to the broader revset `-s reachable(@, mutable())` instead of `-s @`. +* Dropped support for deprecated `jj branch delete`/`forget` `--glob` option. + ### Deprecations * Replacing `-l` shorthand for `--limit` with `-n` in `jj log`, `jj op log` and `jj obslog`. diff --git a/cli/src/commands/branch/delete.rs b/cli/src/commands/branch/delete.rs index f6c68cf7ea..2664c9519a 100644 --- a/cli/src/commands/branch/delete.rs +++ b/cli/src/commands/branch/delete.rs @@ -29,12 +29,8 @@ pub struct BranchDeleteArgs { /// By default, the specified name matches exactly. Use `glob:` prefix to /// select branches by wildcard pattern. For details, see /// https://github.com/martinvonz/jj/blob/main/docs/revsets.md#string-patterns. - #[arg(required_unless_present_any(&["glob"]), value_parser = StringPattern::parse)] + #[arg(required = true, value_parser = StringPattern::parse)] names: Vec, - - /// Deprecated. Please prefix the pattern with `glob:` instead. - #[arg(long, hide = true, value_parser = StringPattern::glob)] - glob: Vec, } pub fn cmd_branch_delete( @@ -44,14 +40,7 @@ pub 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_default(), - "--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 names = find_local_branches(view, &args.names)?; let mut tx = workspace_command.start_transaction(); for branch_name in names.iter() { tx.mut_repo() diff --git a/cli/src/commands/branch/forget.rs b/cli/src/commands/branch/forget.rs index abba038c01..b87cffc6a2 100644 --- a/cli/src/commands/branch/forget.rs +++ b/cli/src/commands/branch/forget.rs @@ -32,12 +32,8 @@ pub struct BranchForgetArgs { /// By default, the specified name matches exactly. Use `glob:` prefix to /// select branches by wildcard pattern. For details, see /// https://github.com/martinvonz/jj/blob/main/docs/revsets.md#string-patterns. - #[arg(required_unless_present_any(&["glob"]), value_parser = StringPattern::parse)] + #[arg(required = true, value_parser = StringPattern::parse)] names: Vec, - - /// Deprecated. Please prefix the pattern with `glob:` instead. - #[arg(long, hide = true, value_parser = StringPattern::glob)] - glob: Vec, } pub fn cmd_branch_forget( @@ -47,14 +43,7 @@ pub 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_default(), - "--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 names = find_forgettable_branches(view, &args.names)?; let mut tx = workspace_command.start_transaction(); for branch_name in names.iter() { tx.mut_repo().remove_branch(branch_name); diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index e139db4d37..b610e63b03 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -265,7 +265,7 @@ Create a new branch Delete an existing branch and propagate the deletion to remotes on the next push -**Usage:** `jj branch delete [NAMES]...` +**Usage:** `jj branch delete ...` ###### **Arguments:** @@ -281,7 +281,7 @@ Forget everything about a branch, including its local and remote targets A forgotten branch will not impact remotes on future pushes. It will be recreated on future pulls if it still exists in the remote. -**Usage:** `jj branch forget [NAMES]...` +**Usage:** `jj branch forget ...` ###### **Arguments:** diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index c706e62485..d21425e2a0 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -376,11 +376,9 @@ fn test_branch_forget_glob() { @ bar-2 foo-1 foo-3 foo-4 230dd059e1b0 ◉ 000000000000 "###); - let (stdout, stderr) = - test_env.jj_cmd_ok(&repo_path, &["branch", "forget", "--glob", "foo-[1-3]"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "forget", "glob:foo-[1-3]"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. Forgot 2 branches. "###); test_env.jj_cmd_ok(&repo_path, &["undo"]); @@ -398,12 +396,10 @@ fn test_branch_forget_glob() { // multiple glob patterns, shouldn't produce an error. let (stdout, stderr) = test_env.jj_cmd_ok( &repo_path, - &["branch", "forget", "foo-4", "--glob", "foo-*", "glob:foo-*"], + &["branch", "forget", "foo-4", "glob:foo-*", "glob:foo-*"], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. - "###); + insta::assert_snapshot!(stderr, @""); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ bar-2 230dd059e1b0 ◉ 000000000000 @@ -412,7 +408,7 @@ fn test_branch_forget_glob() { // Malformed glob let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "forget", "glob:foo-[1-3"]); insta::assert_snapshot!(stderr, @r###" - error: invalid value 'glob:foo-[1-3' for '[NAMES]...': Pattern syntax error near position 4: invalid range pattern + error: invalid value 'glob:foo-[1-3' for '...': Pattern syntax error near position 4: invalid range pattern For more information, try '--help'. "###); @@ -420,10 +416,9 @@ fn test_branch_forget_glob() { // We get an error if none of the globs match anything let stderr = test_env.jj_cmd_failure( &repo_path, - &["branch", "forget", "glob:bar*", "glob:baz*", "--glob=boom*"], + &["branch", "forget", "glob:bar*", "glob:baz*", "glob:boom*"], ); insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. Error: No matching branches for patterns: baz*, boom* "###); } @@ -458,11 +453,9 @@ fn test_branch_delete_glob() { @ bar-2 foo-1 foo-3 foo-4 6fbf398c2d59 ◉ 000000000000 "###); - let (stdout, stderr) = - test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "--glob", "foo-[1-3]"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "glob:foo-[1-3]"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. Deleted 2 branches. "###); test_env.jj_cmd_ok(&repo_path, &["undo"]); @@ -478,9 +471,8 @@ fn test_branch_delete_glob() { // We get an error if none of the globs match live branches. Unlike `jj branch // 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]"]); + let stderr = test_env.jj_cmd_failure(&repo_path, &["branch", "delete", "glob:foo-[1-3]"]); insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. Error: No matching branches for patterns: foo-[1-3] "###); @@ -488,12 +480,10 @@ fn test_branch_delete_glob() { // multiple glob patterns, shouldn't produce an error. let (stdout, stderr) = test_env.jj_cmd_ok( &repo_path, - &["branch", "delete", "foo-4", "--glob", "foo-*", "glob:foo-*"], + &["branch", "delete", "foo-4", "glob:foo-*", "glob:foo-*"], ); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" - Warning: --glob has been deprecated. Please prefix the pattern with `glob:` instead. - "###); + insta::assert_snapshot!(stderr, @""); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ bar-2 foo-1@origin foo-3@origin foo-4@origin 6fbf398c2d59 ◉ 000000000000 @@ -514,7 +504,7 @@ fn test_branch_delete_glob() { // Malformed glob let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "delete", "glob:foo-[1-3"]); insta::assert_snapshot!(stderr, @r###" - error: invalid value 'glob:foo-[1-3' for '[NAMES]...': Pattern syntax error near position 4: invalid range pattern + error: invalid value 'glob:foo-[1-3' for '...': Pattern syntax error near position 4: invalid range pattern For more information, try '--help'. "###); @@ -522,7 +512,7 @@ fn test_branch_delete_glob() { // Unknown pattern kind let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "forget", "whatever:branch"]); insta::assert_snapshot!(stderr, @r###" - error: invalid value 'whatever:branch' for '[NAMES]...': Invalid string pattern kind "whatever:" + error: invalid value 'whatever:branch' for '...': Invalid string pattern kind "whatever:" For more information, try '--help'. Hint: Try prefixing with one of `exact:`, `glob:` or `substring:` diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index 766d0d5e8f..411a6bf98f 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -1190,7 +1190,7 @@ fn test_git_fetch_removed_parent_branch() { "###); // Remove all branches in origin. - test_env.jj_cmd_ok(&source_git_repo_path, &["branch", "forget", "--glob", "*"]); + test_env.jj_cmd_ok(&source_git_repo_path, &["branch", "forget", "glob:*"]); // Fetch branches master, trunk1 and a1 from origin and check that only those // branches have been removed and that others were not rebased because of