Skip to content

Commit

Permalink
Fix parsing for .properties files with - in path (#975)
Browse files Browse the repository at this point in the history
Fixes #974.
  • Loading branch information
jdpopkin authored Feb 19, 2022
1 parent 32e15ce commit 10ff766
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/handlers/grep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
"
}
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 10ff766

Please sign in to comment.