I want Github to reject all Git changes if any commit has an invalid message. Each message should follow the following pattern
<type> <issue>: <message>
e.g.
feat #28: Support multiple file upload
where
type
should be an existing type from a predefined list (feat, fix, ci, ...)issue
should be an existing issue number (if that's even possible to check)message
should be between 1 and 100 characters long
I know about Git hooks running locally. So I could prevent invalid commits configuring a pre-commit hook. But one could simply delete that hook locally, force the commit and push that code to Github. Of course I already configured protected branches so the "attacker" is just able to corrupt his own branches. But I still have to check the messages in the pull requests on my own.
It would be nice to configure Github to reject every change with a smart error message
abc #28: message goes here
gets rejected with the message
Rejected because 'abc' is not a valid type
feat #99999: message goes here
gets rejected with the message
Rejected because the issue doesn't exist
feat #28:
gets rejected with the message
Rejected because the message is empty
Does someone know how to configure such a "security" feature if that's even possible?
Imagine many people are working on the project and everyone should follow the rules. Commit messages should have a common style so it's easy to read the commit history. I know that only maintainers can directly push to the repo but one might "forget" the rules and create a push containing commits violating the rules.