-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Is your feature request related to a problem? Please describe.
Include all sources of gitignore patterns.
I have user and host specific ignore rules in ~/$USER/.gitignore
that Black is unaware of.
>>> cat ~/.gitignore
*.swp
*.swo
.DS_Store
.ropeproject
.mypy_cache
.ccls-cache
.clangd
And just started adding black into my workflow at a project root level instead of an individual call to a specific file.
So the file finding process included python files in the .ropeproject folder of this project. (I only occasionally setup rope when I need it.)
Describe the solution you'd like
I would like to have the user/host gitignore files respected when project root .gitignore
is used.
get_gitignore
could use similar logic to find_user_pyproject_toml
to add the lines from the user ignore file.
Unfortunately this file is specified as either a default location or with a git configuration.
From https://git-scm.com/docs/gitignore
Which file to place a pattern in depends on how the pattern is meant to be used.
Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.
Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.
Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.
Describe alternatives you've considered
Add user specific files to project's .gitignore
It wouldn't hurt to add vim and other tools to the project specific ignore files, but feels like I would be adding many user settings to a project. Although arguments for .DS_Store
being in the project's .gitignore
is applicable for a project that is typically developed on Mac OS, it is just on the threshold.
Adding vim swap files seems more user vs. project specific.
A workaround that I see now from researching for this bug would be to use $GIT_DIR/info/exclude
but would also need to then have that path added into black.
Additional context
Honestly this may be a non-issue, as it only affects my worktrees and not other users.
It may break future use of --check as unintentional user folders were included...