Created
May 16, 2023 07:55
-
-
Save chmouel/c4b43772d8809b68102a6338f2516f9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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