My project uses a single gitHub repository in which both Mac and Windows users commit their code on. I have set up a client side hook in order to include the JIRA Id in the commit message by modifying the commit-message hook in the hooks folder. However, as client side hooks cannot be published, writing a script and including it in the repo would help modify the file. Is it possible to write a common script that would work on both windows and Mac. The script needs to do the following.
- Rename the commit-msg.sample to commit-msg
- Replace the contents of the file to the code below
Code below
commit_regex='(ISSUE-[0-9]+|merge)'
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('ISSUE-1111') or 'Merge'"
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi