I want to set up a GitHub project to use conventional-changelog standard version to generate its changelog. We use a squash and merge workflow to merge PRs into our main development branch.
Is there a way that I can enforce that the commit message of the squashed commit follows a specific format?
Ideally this would work nicely with the GitHub UI, such as showing as a failing check. I realize I could simply write a browser extension to enforce this, but then everyone working on the project would need to install the extension which is too high of a barrier to entry for an open source project.
It's not clear if you're intending for this to be on GitHub Public or Enterprise. I haven't tried to implement this on GitHub Public.
On Enterprise the process is to create a pre-receive hook for the specific repo you're interested in protecting. Keep in mind, unless you're willing to upload a new environment, you'll be limited in the tools that your pre-receive hook can use.
The best details can be found at: https://help.github.com/enterprise/2.11/admin/guides/developer-workflow/creating-a-pre-receive-hook-script/
Essentially the flow will be looking something like:
#!/usr/bin/env bash
#
DEFAULT_BRANCH=$(git symbolic-ref HEAD)
while read oldrev newrev refname; do
# We only care about these changes to master
if [[ "${refname}" != "${DEFAULT_BRANCH:=refs/heads/master}" ]]; then
exit 0
fi
# branch or tag got deleted
if [ "${newrev}" = "${zero_commit}" ]; then
continue
fi
# branch or tag is being created
if [ "${oldrev}" = "${zero_commit}" ]; then
continue
fi
for COMMIT_HASH in `git rev-list ${oldrev}..${newrev}`;
do
# Add your COMMIT_HASH scrubbing process here
# On failure exit 1
done
done
exit 0
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