Skip to content

Commit

Permalink
Merge pull request #346 from sharemindteam/feat/issue_number_husky_344
Browse files Browse the repository at this point in the history
[Feat] husky로 commit 시 이슈 넘버 자동할당하는 로직 추가
  • Loading branch information
rmdnps10 authored Jul 12, 2024
2 parents 711bf2f + 1f4e8e1 commit b99e365
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 2 deletions.
17 changes: 17 additions & 0 deletions addIssueNumber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

COMMIT_MSG_FILE=$1

# 현재 브랜치 이름 가져오기
branch_name=$(git rev-parse --abbrev-ref HEAD)

# 브랜치 이름에서 마지막 숫자 추출
issue_number=$(echo ${branch_name} | grep -o '[0-9]*$')

# 커밋 메시지 파일의 첫 번째 줄 읽기
first_line=$(head -n1 ${COMMIT_MSG_FILE})

# 브랜치 이름에 숫자가 있는 경우에만 이슈 번호를 커밋 메시지 첫 번째 줄 끝에 추가
if [ -n "$issue_number" ]; then
sed -i ".bak" "1s/\$/ (#$issue_number)/" ${COMMIT_MSG_FILE}
fi
187 changes: 186 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"husky": {
"hooks": {
"prepare-commit-msg": "./addIssueNumber.sh $HUSKY_GIT_PARAMS"
}
},
"eslintConfig": {
"extends": [
"react-app",
Expand All @@ -59,6 +64,7 @@
]
},
"devDependencies": {
"@types/react-dom": "^18.2.18"
"@types/react-dom": "^18.2.18",
"husky": "4"
}
}

0 comments on commit b99e365

Please sign in to comment.