Skip to content

Instantly share code, notes, and snippets.

@slaysd
Last active February 26, 2020 02:58
Show Gist options
  • Save slaysd/15c3f6cc02878cced00e4267997ab05f to your computer and use it in GitHub Desktop.
Save slaysd/15c3f6cc02878cced00e4267997ab05f to your computer and use it in GitHub Desktop.
지라 티켓넘버 자동 부여
#!/bin/bash
# Copy in .git/hooks/prepare-commit-msg
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop release hotfix)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
JIRA_ID=`echo $BRANCH_NAME | egrep -o '[A-Z]+-[0-9]+'`
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "$JIRA_ID" $1)
if [ -n $JIRA_ID ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
sed -i.bak -e "1s/^/[$JIRA_ID] /" $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment