-
-
Save maxtortime/a03e3289db5d600899eda5dfa5e3b6cf to your computer and use it in GitHub Desktop.
feature/sample 이름을 가진 브랜치일때 커밋 메시지 앞에 [sample] 을 붙여주는 훅
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/sh | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master develop release hotfix) | |
fi | |
BRANCH_NAME=$(git symbolic-ref --short HEAD 2> /dev/null) | |
if [ $? -eq 0 ]; then | |
BRANCH_NAME="${BRANCH_NAME##*/}" | |
JIRA_ID=`echo $BRANCH_NAME | grep -oE '[A-Z]+-[0-9]+'` | |
JIRA_ID="[$JIRA_ID]" | |
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$") | |
# JIRA_ID가 존재하고 master develop release hotfix 브랜치가 아닐 때만 동작함 | |
if [ -n $JIRA_ID ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] ; then | |
sed -i.bak -e "1s/^/$JIRA_ID /" $1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment