mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 18:27:38 +00:00
revset: add support for explicit substring:"..." prefix
git-branchless calls it a substring, so let's do the same. FWIW, I copied literal:_ from Mercurial, but it's exact:_ in git-branchless. I have no idea which one is preferred. Since this feature isn't released, we can freely change it if exact:_ makes more sense. https://github.com/arxanas/git-branchless/wiki/Reference:-Revsets#patterns
This commit is contained in:
parent
2062abdc9d
commit
ebdc22a65e
2 changed files with 9 additions and 3 deletions
|
@ -141,8 +141,8 @@ revsets (expressions) as arguments.
|
|||
|
||||
Functions that perform string matching support the following pattern syntax.
|
||||
|
||||
* `"substring"`: Matches strings that contain `substring`.
|
||||
* `literal:"string"`: Matches strings exactly equal to `string`.
|
||||
* `"string"`, `substring:"string"`: Matches strings that contain `string`.
|
||||
* `literal:"string"`: Matches strings exactly equal to `string`.
|
||||
|
||||
## Aliases
|
||||
|
||||
|
|
|
@ -1324,7 +1324,7 @@ fn parse_function_argument_to_string_pattern(
|
|||
};
|
||||
match kind.as_ref() {
|
||||
"literal" => StringPattern::Literal(needle.clone()),
|
||||
// TODO: maybe add explicit kind for substring match?
|
||||
"substring" => StringPattern::Substring(needle.clone()),
|
||||
_ => {
|
||||
// TODO: error span can be narrowed to the lhs node
|
||||
return Err(make_error(format!(
|
||||
|
@ -2699,6 +2699,12 @@ mod tests {
|
|||
"foo".to_owned()
|
||||
)))
|
||||
);
|
||||
assert_eq!(
|
||||
parse(r#"branches(substring:"foo")"#),
|
||||
Ok(RevsetExpression::branches(StringPattern::Substring(
|
||||
"foo".to_owned()
|
||||
)))
|
||||
);
|
||||
assert_eq!(
|
||||
parse(r#"branches("literal:foo")"#),
|
||||
Ok(RevsetExpression::branches(StringPattern::Substring(
|
||||
|
|
Loading…
Reference in a new issue