forked from mirrors/jj
cli: deprecate branch delete/forget --glob option in favor of glob: syntax
I'm not going to remove --glob anytime soon, but I won't add --glob option to new commands.
This commit is contained in:
parent
c3f167e6cc
commit
8dbe12da2a
3 changed files with 28 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ pub struct BranchDeleteArgs {
|
|||
#[arg(required_unless_present_any(&["glob"]), value_parser = parse_name_pattern)]
|
||||
pub names: Vec<StringPattern>,
|
||||
|
||||
/// 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<StringPattern>,
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,8 @@ pub struct BranchForgetArgs {
|
|||
#[arg(required_unless_present_any(&["glob"]), value_parser = parse_name_pattern)]
|
||||
pub names: Vec<StringPattern>,
|
||||
|
||||
/// 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<StringPattern>,
|
||||
}
|
||||
|
||||
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue