From 10ff766a65f23d4f48cefaa457a660bfc090d668 Mon Sep 17 00:00:00 2001 From: Jackson Popkin Date: Sat, 19 Feb 2022 12:24:23 -0500 Subject: Fix parsing for .properties files with `-` in path (#975) Fixes #974. --- src/handlers/grep.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 ) " } @@ -655,6 +655,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 = -- cgit v1.2.3