Last active
December 16, 2022 06:55
-
-
Save markruler/e93d2cfc1339d9a03c2ad8ebf1c5005a to your computer and use it in GitHub Desktop.
GitHub 커밋 메세지에 JIRA 이슈번호 자동으로 넣어주기
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 | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master develop release hotfix) | |
fi | |
PROJECT_ID=ASA | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_NAME="${BRANCH_NAME##*/}" | |
JIRA_ID=`echo $BRANCH_NAME | egrep -o "$PROJECT_ID-[0-9]+"` | |
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$") | |
COMMIT_MSG_HEAD=$(head $1 -n 1) | |
BRANCH_IN_COMMIT=$(grep -c $COMMIT_MSG_HEAD) | |
if [ -n $JIRA_ID ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then | |
sed -i.bak -e "1s/^/$JIRA_ID #time /" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
이 스크립트 당시 몇 주 써보고 안 쓰고 있습니다. rebase 할 때 커밋 할 때마다 저 스크립트가 동작해서 더 불편하네요. 이슈 번호가 있는데 또 붙이기도 하고요.