Skip to content
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

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

Conversation

Alex-ley-scrub
Copy link
Contributor

@Alex-ley-scrub Alex-ley-scrub commented Oct 27, 2024

/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

…sure the `ignore::Walk` is correctly skipping files based on nested .gitignore files

see getgrit#539
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

17 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@Alex-ley-scrub
Copy link
Contributor Author

Alex-ley-scrub commented Oct 27, 2024

@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:

// root .gitignore has *.rst and *.pyi and file3.py
// src .gitignore has !module1/*.pyi and !module2/*.rst
// src/module1 .gitignore has !*.rst
// src/module2 .gitignore has file1.py and !file3.py

// in this folder we should process file1.py and file2.pyi BUT NOT file3.py
let module1 = fixture_dir.join("src/module1");
let mut cmd = get_test_cmd()?;
cmd.arg("apply")
.arg("`object` => ``")
.arg(".")
.arg("--lang=py")
.arg("--force")
.current_dir(&module1);

// in this folder we should ONLY process file3.py and NOT file2.pyi NOR file1.py
let module2 = fixture_dir.join("src/module2");
let mut cmd = get_test_cmd()?;
cmd.arg("apply")
.arg("`object` => ``")
.arg(".")
.arg("--lang=py")
.arg("--force")
.current_dir(&module2);

image

@Alex-ley-scrub
Copy link
Contributor Author

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
Copy link
Contributor

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

@morgante morgante closed this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.gitignore from root isn't used when running in a subdirectory
2 participants