File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # .git/hooks/commit-msg
3+
4+ msg_file=" $1 "
5+ commit_msg=" $( < " $msg_file " ) "
6+
7+ regex=" ^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) \\ ( #[0-9]+ \\ ) : .+$"
8+
9+ if [[ ! $commit_msg =~ $regex ]]; then
10+ echo " ❌ 메시지 형식 에러: 타입 ( #이슈 ) : 설명"
11+ exit 1
12+ fi
13+
14+ echo " ✅ 커밋 메시지 형식 OK"
Original file line number Diff line number Diff line change 11#! /bin/bash
2+ # .git/hooks/pre-commit
23
3- # Git 디렉토리 위치
4- git_dir=$( git rev-parse --git-dir 2> /dev/null) || { echo " ❌ Git 저장소만 지원한다." ; exit 1; }
4+ echo " 🔨 Gradle 빌드 검증…"
55
6- # 방금 작성된 커밋 메시지 읽기
7- commit_msg=" $( < " $git_dir /COMMIT_EDITMSG" ) "
8-
9- # 메시지 패턴 정의
10- regex=" ^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) *\([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) *: .+$"
11-
12- if [[ " $commit_msg " =~ $regex ]]; then
13- echo " ✅ 커밋 메시지 형식이 올바릅니다."
14- else
15- echo " ❌ 커밋 메시지 형식이 잘못되었습니다."
16- echo " 형식: 타입(#이슈번호) : 설명"
17- exit 1
18- fi
19-
20- # 기존에 하던 Gradle 빌드 검증도 이어서 실행
21- echo " Gradle 빌드 검증 시작..."
226if ! ./gradlew clean build --no-daemon; then
23- echo " ❌ 빌드 실패! 커밋 중단. "
7+ echo " ❌ 빌드 실패— 커밋 중단"
248 exit 1
25- else
26- echo " ✅ 빌드 성공! 커밋 계속."
27- exit 0
289fi
10+
11+ echo " ✅ 빌드 성공"
You can’t perform that action at this time.
0 commit comments