How to enforce a commit message policy when doing squash merge via GitHub Web UI?

Viewed 337

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?

1 Answers
Related