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

.gitignore from parent git repository is used while it shouldn't #882

Open
fry69 opened this issue Oct 6, 2024 · 2 comments
Open

.gitignore from parent git repository is used while it shouldn't #882

fry69 opened this issue Oct 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fry69
Copy link

fry69 commented Oct 6, 2024

My setup may be not exactly standard, but deptry is the only tool that has a problem with it:

Up in my filesystem hierarchy there lingers a Git repository which ignores everything (*) and only a few files/directories are excluded from this catch all ignore. This works 100% fine with VSCode Git, command line Git and every other Git related tool I can think of.

Only deptry refuses to find any file with this setup, as it somehow climbs up in hierarchy to find my .gitignore->

Scanning 0 file...

Is there a way to fix this gracefully?

@mkniewallner mkniewallner added the bug Something isn't working label Oct 7, 2024
@mkniewallner
Copy link
Collaborator

Agree that we should avoid reading .gitignore from parents directories outside the path where deptry is invoked. We could disable parents when constructing the directory iterator here.

But testing a bit the changes, this made me realise that we probably don't handle .gitignore properly today. If we disable reading parents, given the following structure:

.
├── requirements.txt
└── src
    └── foo.py

where .gitignore contains *.

$ deptry .
[...]
Scanning 0 file...
[...]
$ deptry src
[...]
Scanning 1 file...
[...]

Reading .gitignore file is relative to the directory passed as a positional argument, which is probably not what we want. Seems to me that reading the file from the location deptry itself is invoked would make more sense, although we should likely also respect .gitignore in sub-directories (which is probably something that the library we use does automatically).

@mkniewallner mkniewallner self-assigned this Oct 7, 2024
@fry69
Copy link
Author

fry69 commented Oct 7, 2024

Tiny addition: There must be some kind of clever library at work, as even if I move the git ignore patterns from .gitignore to .git/info/exclude, they still get found in the git repository up in the parent hierarchy.

@mkniewallner mkniewallner changed the title Bug: Do not inlcude .gitignore from parent git repository Do not include .gitignore from parent git repository Oct 8, 2024
@mkniewallner mkniewallner changed the title Do not include .gitignore from parent git repository .gitignore from parent git repository is used while it shouldn't Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants