Closed mcous closed 1 month ago
Thanks @mcous! Very much appreciate you made the leap from "dang this thing doesn't work at all" to a PR with a fix with tests! Will be released shortly.
:rocket: This pull request is included in v5.31.0. See Release 5.31.0 for release notes.
Using Knip in a commercial project? Please consider becoming a sponsor.
Just started using
knip
today and it was instrumental in some really nice cleanup in our codebase. I hit #795 right off the bat, though, and it took me a while to figure out what was going on. I figured I could say "thanks" by opening up a quick PR to fix the issue!The logic in the gitignore parser that strips trailing
# ...
off of.gitignore
lines appears to be wrong. In my testing, you cannot add a comment to the end of a.gitignore
line in this manner (syntax highlighting be damned):This tracks with git's documentation (emphasis mine) as well as my own messing around with git:
The previous parsing logic (added in https://github.com/webpro-nl/knip/commit/e455527fb2cc58981775ad538f5d4a64a3c70b5b) stripped all non-backslashed
#...
out. I updated the logic to only strip a leading\
, if it's in front of a hash, so the following cases will be handled properly: