I'm trying to do a hook for a message that you're about to commit on git. What I usually do when about to commit is [SOME_DESCRIPTION] Refs #[0-9]+
I've never done shell scripting before but I'm fairly adept at programming in general. I'm trying to write a script in commit-msg that will validate if the current that you're trying to save has the pattern "*Refs #[0-9]+". But I have no shell syntax experience and not too much linux.
- I think $1 is to get the current commit message, but I'm probably wrong.
- And my way of checking for the pattern is probably way wrong
requireTicketRef=$1
if [[ $requireTicketRef == *Refs \#[0-9]+ ]]
then
echo "Contains ticket reference"
exit 0
else
echo "Need to add ticket reference"
exit 1
fi