Created
September 25, 2020 09:39
-
-
Save aabouzaid/20b9d48e150777dcb7833e7b3fe3538b to your computer and use it in GitHub Desktop.
Add JIRA ticket ID to Git commit message
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
#!/bin/bash | |
COMMIT_MSG_FILE=$1 | |
TICKET_ID_PATTERN="INFRA-[0-9]+" | |
TICKET_ID=$(git symbolic-ref --short HEAD | egrep -o "${TICKET_ID_PATTERN}") | |
TICKET_MSG_IN_COMMIT=$(grep -c "Related to: ${TICKET_ID}" ${COMMIT_MSG_FILE}) | |
if [[ -n "${TICKET_ID}" && ${TICKET_MSG_IN_COMMIT} -lt 1 ]]; then | |
echo -e "\nRelated to: ${TICKET_ID}" >> ${COMMIT_MSG_FILE} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment