We do have a commit hook to enforce messages that follow config-conventional:
package.json
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "yarn format:check",
"pre-push": "yarn run test"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"scope-case": [
0,
"always",
"pascal-case"
]
}
},
However, if me merge a PR with the squash strategy (via github web ui) then it is possible that a commit message is being sneaked in as the policy is not being enforced here:
feat: [TICKET-209] add completion tests
Added build instructions to README.md <-- Added via squash
feat: [TICKET-208] improve tests
This part of the GitHub history is the result of the 2nd line being added through a squash and therefore not being checked/rejected.
Is there a solution to reject invalid commit messages which are added via squash on github web ui?
If your priority is making sure no commits enter the main branch without the right format, then "Merge queue + Github Action to check commit msg" might solve this problem: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue (note this feature is in public beta)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With