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

Add support for user git ignore configuration file. #2929

Open
hardkrash opened this issue Mar 16, 2022 · 0 comments
Open

Add support for user git ignore configuration file. #2929

hardkrash opened this issue Mar 16, 2022 · 0 comments
Labels
C: configuration CLI and configuration C: file collection Related to file collection (e.g. gitignore & cache) or file discovery and all of its configuration. T: enhancement New feature or request

Comments

@hardkrash
Copy link

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...

@hardkrash hardkrash added the T: enhancement New feature or request label Mar 16, 2022
@JelleZijlstra JelleZijlstra added C: configuration CLI and configuration C: file collection Related to file collection (e.g. gitignore & cache) or file discovery and all of its configuration. labels Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration CLI and configuration C: file collection Related to file collection (e.g. gitignore & cache) or file discovery and all of its configuration. T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants