Skip to content

Instantly share code, notes, and snippets.

@choubari
Created October 5, 2022 18:27
Show Gist options
  • Save choubari/c89b685c334939d581489c537b5bda2f to your computer and use it in GitHub Desktop.
Save choubari/c89b685c334939d581489c537b5bda2f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the commit message from file, which just contains the message
commitMessage=$(cat $1)
# Ensure each commit message is formatted with a project key (eg: JIRA-1234)
pattern="([A-z]{1,5}-[0-9]{1,})+"
if [[ ! "$commitMessage" =~ $pattern ]]; then
echo "Please add an issue number to the commit message: $commitMessage"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment