mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-14 16:37:42 +00:00
lib: improve error message for invalid string pattern, suggesting to use one of the known one
This commit is contained in:
parent
8600750fce
commit
93c707a469
4 changed files with 4 additions and 4 deletions
|
@ -396,7 +396,7 @@ fn test_branch_delete_glob() {
|
||||||
// Unknown pattern kind
|
// Unknown pattern kind
|
||||||
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "forget", "whatever:branch"]);
|
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["branch", "forget", "whatever:branch"]);
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
insta::assert_snapshot!(stderr, @r###"
|
||||||
error: invalid value 'whatever:branch' for '[NAMES]...': Invalid string pattern kind "whatever"
|
error: invalid value 'whatever:branch' for '[NAMES]...': Invalid string pattern kind "whatever:", try prefixing with one of `exact:`, `glob:` or `substring:`
|
||||||
|
|
||||||
For more information, try '--help'.
|
For more information, try '--help'.
|
||||||
"###);
|
"###);
|
||||||
|
|
|
@ -157,7 +157,7 @@ fn test_bad_function_call() {
|
||||||
1 | branches(bad:pattern)
|
1 | branches(bad:pattern)
|
||||||
| ^---------^
|
| ^---------^
|
||||||
|
|
|
|
||||||
= Invalid arguments to revset function "branches": Invalid string pattern kind "bad"
|
= Invalid arguments to revset function "branches": Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:`
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "root()::whatever()"]);
|
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "root()::whatever()"]);
|
||||||
|
|
|
@ -2932,7 +2932,7 @@ mod tests {
|
||||||
parse(r#"branches(bad:"foo")"#),
|
parse(r#"branches(bad:"foo")"#),
|
||||||
Err(RevsetParseErrorKind::InvalidFunctionArguments {
|
Err(RevsetParseErrorKind::InvalidFunctionArguments {
|
||||||
name: "branches".to_owned(),
|
name: "branches".to_owned(),
|
||||||
message: r#"Invalid string pattern kind "bad""#.to_owned()
|
message: r#"Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:`"#.to_owned()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -25,7 +25,7 @@ use thiserror::Error;
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum StringPatternParseError {
|
pub enum StringPatternParseError {
|
||||||
/// Unknown pattern kind is specified.
|
/// Unknown pattern kind is specified.
|
||||||
#[error(r#"Invalid string pattern kind "{0}""#)]
|
#[error(r#"Invalid string pattern kind "{0}:", try prefixing with one of `exact:`, `glob:` or `substring:`"#)]
|
||||||
InvalidKind(String),
|
InvalidKind(String),
|
||||||
/// Failed to parse glob pattern.
|
/// Failed to parse glob pattern.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
|
Loading…
Reference in a new issue