Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created May 16, 2023 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmouel/c4b43772d8809b68102a6338f2516f9a to your computer and use it in GitHub Desktop.
Save chmouel/c4b43772d8809b68102a6338f2516f9a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
TMP=$(mktemp /tmp/.mm.XXXXXX)
clean() { rm -f ${TMP}; }
trap clean EXIT
BRANCH=$(git symbolic-ref HEAD --short)
if [[ ${BRANCH} =~ issue-([0-9]*) ]];then
if ! grep -Eqi "(\b)?(Close|Fixe|Fix)(s)? (#)?${BASH_REMATCH[1]}" ${COMMIT_MSG_FILE};then
if [[ $(head -1 ${COMMIT_MSG_FILE}) != "" ]];then
sed -i "2aFixes #${BASH_REMATCH[1]}" ${COMMIT_MSG_FILE}
exit
fi
gh workon -c > ${TMP}
cat ${COMMIT_MSG_FILE} >> ${TMP}
mv ${TMP} ${COMMIT_MSG_FILE}
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment