-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect global .gitignore when excludesFile path uses surrounding double quotes #2629
Respect global .gitignore when excludesFile path uses surrounding double quotes #2629
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! But the regex here looks too permissive. It accepts any sequence of whitespace and quotes. It probably should be \s*"?\s*
or something.
And please use a literal quote instead of its hex escape. You'll want to use r#"..."#
for the string syntax.
@BurntSushi , Thanks for the feedback. I've gone ahead and made the changes you suggested. I added an extra test to check if more than one pair of double quotes surrounding the path is valid or not. I can remove it if it's overkill but let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does allow a quote on one side but not the other, but we're never going to get this exactly right with using a regex to parse this file anyway.
Also, in the future, PRs like this should just be one commit. So changes should be fixed up into one commit and then force pushed. |
super::expand_tilde("~/foo/bar") | ||
); | ||
} | ||
#[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also, code should follow the style of the surrounding code. In this case, there should be a blank
line separating test functions.
(You don't need to do this now. I've done it for you and this PR will get rolled up into another bigger one.)
Related Issue: #2392
Summary of problem:
In a .gitconfig file, a user may specify additional file patterns they may want to ignore when committing changes by using the
core.excludesFile
setting. RipGrep respects these file patterns as well.Git also handles file paths that are surrounded by double quotes like
RipGrep's logic does not handle for double quotes.
Changes
The regex used to parse the
excludesFile
section of the .gitconfig adds double quotes (\x22) as a part of the parsing pattern.Tests
Wrote
parse_excludes_file4
for unit testingManually tested from issue's example: