Feature request: Respect .gitignore'd files
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
.gitignorefile. - 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
.gitignoreor on using git ls-files - [ ] Implement filtering in
runmethod - [ ] Add tests for nested
.gitignorefiles
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada: