summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJackson Popkin <jackson@donorschoose.org>2022-02-19 12:24:23 -0500
committerGitHub <noreply@github.com>2022-02-19 12:24:23 -0500
commit10ff766a65f23d4f48cefaa457a660bfc090d668 (patch)
tree50045092d743163e2375fc38b0b67e26af8bfd8f
parent32e15ce6fb3cbc9648f189f197206ab29aa329c4 (diff)
Fix parsing for .properties files with `-` in path (#975)
Fixes #974.
-rw-r--r--src/handlers/grep.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/handlers/grep.rs b/src/handlers/grep.rs
index e8f115eb..eca33e22 100644
--- a/src/handlers/grep.rs
+++ b/src/handlers/grep.rs
@@ -345,7 +345,7 @@ fn make_grep_line_regex(regex_variant: GrepLineRegex) -> Regex {
( # 1. file name (colons not allowed)
[^:|\ ] # try to be strict about what a file path can start with
[^:]* # anything
- [^\ ]\.[^.\ :=-]{1,6} # extension
+ [^\ ]\.[^.\ :=-]{1,10} # extension
)
"
}
@@ -656,6 +656,24 @@ mod tests {
}
#[test]
+ fn test_parse_grep_n_match_directory_name_with_dashes() {
+ let fake_parent_grep_command =
+ "/usr/local/bin/git --doesnt-matter grep --nor-this nor_this -- nor_this";
+ let _args = FakeParentArgs::once(fake_parent_grep_command);
+
+ assert_eq!(
+ parse_grep_line("etc/META-INF/foo.properties:4:value=hi-there"),
+ Some(GrepLine {
+ path: "etc/META-INF/foo.properties".into(),
+ line_number: Some(4),
+ line_type: LineType::Match,
+ code: "value=hi-there".into(),
+ submatches: None,
+ })
+ );
+ }
+
+ #[test]
fn test_parse_grep_no_match() {
let fake_parent_grep_command =
"/usr/local/bin/git --doesnt-matter grep --nor-this nor_this -- nor_this";