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

Feature request: Respect .gitignore'd files #428

Closed
3 tasks
LordFckHelmchen opened this issue Mar 15, 2024 · 2 comments
Closed
3 tasks

Feature request: Respect .gitignore'd files #428

LordFckHelmchen opened this issue Mar 15, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@LordFckHelmchen
Copy link

LordFckHelmchen commented Mar 15, 2024

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 Feature request: exclude/ignore option #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
@LordFckHelmchen LordFckHelmchen added the enhancement New feature or request label Mar 15, 2024
Copy link

welcome bot commented Mar 15, 2024

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! 🎉

@LordFckHelmchen LordFckHelmchen changed the title Respect .gitignore'd files Feature request: Respect .gitignore'd files Mar 15, 2024
@hukkin
Copy link
Owner

hukkin commented Oct 21, 2024

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.

@hukkin hukkin closed this as completed Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants