getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.
https://docs.grit.io/
MIT License
3.17k stars 82 forks source link

fix: 539 ensure correctly skipping files based on nested .gitignore files #567

Closed Alex-ley-scrub closed 3 weeks ago

Alex-ley-scrub commented 3 weeks ago

/claim #539

fixes #539

see https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html#ignore-rules

Greptile Summary

This is an auto-generated summary

Hi! Looks like you've reached your API usage limit. You can increase it from your account settings page here: app.greptile.com/settings/usage

Alex-ley-scrub commented 3 weeks ago

@morgante - I can't seem to replicate what you are seeing in #539 ? Do you have an example command that fails?

These commands (now in a test) work as I would expect them to? Correct files are ignored.

cd src/module1
grit apply '`object` => ``' . --lang=py --force

cd src/module2
grit apply '`object` => ``' . --lang=py --force

I think that the ignore::Walk already does this (see description on docs.rs) - I do also have some code locally that also manually adds the .gitignore files to the ignore::Walk but there's no point pushing it if it is not needed. Although if you can share a command with me that does fail to ignore them - then I'm happy to push it of course.

I added a test that I think captures the desired behaviour:

https://github.com/getgrit/gritql/blob/a7d5bd32666163fc6069a74cf7ee6efca022f0a4/crates/cli_bin/tests/apply.rs#L2925-L2928

https://github.com/getgrit/gritql/blob/a7d5bd32666163fc6069a74cf7ee6efca022f0a4/crates/cli_bin/tests/apply.rs#L2930-L2938

https://github.com/getgrit/gritql/blob/a7d5bd32666163fc6069a74cf7ee6efca022f0a4/crates/cli_bin/tests/apply.rs#L2959-L2967

image
Alex-ley-scrub commented 3 weeks ago

I think that the ignore::Walk already does this (see description on docs.rs) - I do also have some code locally that also manually adds the .gitignore files to the ignore::Walk but there's no point pushing it if it is not needed. Although if you can share a command with me that does fail to ignore them - then I'm happy to push it of course.

image
morgante commented 3 weeks ago

Thanks for investigating, it looks like I'm unable to reproduce this too. Sorry for the mixup!