Feature request: Respect .gitignore'd files
Closed this issue · 2 comments
Context
I really like the possibility to remove formatting considerations from my developers minds. Mdformat is a great tool to add for this endevour. My use case is running the mdformat linter in build/ci scripts where we don't have pre-commit available.
However, currently any *.md files are picked up - including any files in .gitignored folders like local virtual environments or Python caches. To assure that we pick up any new markdown files in the repository, we can not simply whitelist certain folders, but want to scan the whole repo instead. Ideally we also don't want to keep a separate list of ignored files, as there should be a single ground truth.
Proposal
- Add an option to respect a
.gitignore
file. - If the option is set, the listed paths/files are ignored during discovery of the Markdown files.
- Consider how to find the .gitignore file. It should be on the same level as the config file/pyproject.toml file on repo root. But that might not always be the case (e.g. for mono-repos). Alternatively you could subprocess-call
git ls-files
, which will provide a list of files to process. - This issues is related to #359
Tasks and updates
- Decide on discovery mechanism for
.gitignore
or on using git ls-files - Implement filtering in
run
method - Add tests for nested
.gitignore
files
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! 🎉
With the --exclude
feature (#359) implemented I think this should be less of an issue.
I really wouldn't want to
a) look into other tools' configuration
b) add a dependency for parsing .gitignore (or a slow subprocess call)
c) make configuration sourcing more complicated
so perhaps mdformat's own --exclude
can be enough?
For most users the best solution is to use a tool like pre-commit that is built around git and these sorts of use cases (though I notice this doesn't work for LordFckHelmchen).
Closing as not planned, at least for now.