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

Allow no-commit-to-branch to block commits based on regex matching #375

Closed
marcjay opened this issue Apr 9, 2019 · 4 comments
Closed

Allow no-commit-to-branch to block commits based on regex matching #375

marcjay opened this issue Apr 9, 2019 · 4 comments

Comments

@marcjay
Copy link
Contributor

marcjay commented Apr 9, 2019

Hopefully not alone in wanting this functionality - our use case is we have multiple release branches (e.g. release/1.0.0, release/2.0.0) and no commits should be made to these branches directly, only via pull requests.

This would be to add wildcard matching, so that with args: [--branch, master, --branch, release/*] it would cause pre-commit to fail if a commit is attempted on any of: master, release/1.0.0 or release/2.0.0

@asottile
Copy link
Member

asottile commented Apr 9, 2019

Seems fine, let's use --pattern as a separate argument and use regular expressions instead of glob / fnmatch

@marcjay
Copy link
Contributor Author

marcjay commented Apr 10, 2019

Sure, I'll re-work the PR. Just want to double check - do you see the example above becoming:

args: [--branch, master, --pattern, release/.*]

i.e. the branch and pattern args would become an OR match, as opposed to the two args being mutually exclusive and needing to do:

args: [--pattern, master|(release/.*)]

@asottile
Copy link
Member

the first one sounds good 👍

@marcjay marcjay changed the title Allow no-commit-to-branch to block commits based on wildcard matching Allow no-commit-to-branch to block commits based on regex matching Apr 20, 2019
@asottile
Copy link
Member

via #376

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

No branches or pull requests

2 participants