Skip to content

Commit 68ebc16

Browse files
authored
Merge pull request #16 from EntryDSM/refactor/15-pre-commit-separation
Refactor/15 pre commit 분리
2 parents 05da37c + 690639e commit 68ebc16

2 files changed

Lines changed: 19 additions & 22 deletions

File tree

.github/hooks/commit-msg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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"

.github/hooks/pre-commit

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
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 빌드 검증 시작..."
226
if ! ./gradlew clean build --no-daemon; then
23-
echo "❌ 빌드 실패! 커밋 중단."
7+
echo "❌ 빌드 실패커밋 중단"
248
exit 1
25-
else
26-
echo "✅ 빌드 성공! 커밋 계속."
27-
exit 0
289
fi
10+
11+
echo "✅ 빌드 성공"

0 commit comments

Comments
 (0)