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

Support glob filename patterns #853

Open
reegnz opened this issue Oct 3, 2024 · 2 comments
Open

Support glob filename patterns #853

reegnz opened this issue Oct 3, 2024 · 2 comments

Comments

@reegnz
Copy link

reegnz commented Oct 3, 2024

When working with files, policy-bot should be providing basic glob support.

When working with common unix tools, glob-support tends to be either built-in, or augmented by the wrapping shell evaluating globs. It's not that common using regex to match filename patterns.

Using filename pattern matching is arguable also more secure than raw regex.

Please support either globs or gitignore patterns (which also resemble globs).

Seems like go has glob functionality already built into it's standard library, and is much more performant in matching filenames than regex:
https://github.com/golang/go/blob/master/src/path/filepath/match.go#L44

I imagine config could look like this:

changed_files:
  glob: true
  paths:
  - **/*.yaml
  - **/some/**/pattern/*.py
  
@asvoboda
Copy link
Member

asvoboda commented Oct 3, 2024

Golang's default glob doesn't actually support **: golang/go#11862. To support this, we'd likely need to use github.com/bmatcuk/doublestar.

I think we'd be open to a potential contribution here if you'd like, but internally regexes work quite well for us.

@reegnz
Copy link
Author

reegnz commented Oct 4, 2024

I'll see if I can make that change and send a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants