Skip to content

Commit 05da37c

Browse files
authored
Merge pull request #14 from EntryDSM/refactor/13-pre-commit
Refactor/13 pre commit 재설정
2 parents aae4fc6 + ad2f611 commit 05da37c

5 files changed

Lines changed: 30 additions & 43 deletions

File tree

.gitconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[core]
2+
hooksPath = ".github/hooks"

.github/hooks/pre-commit

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Git 디렉토리 위치
4+
git_dir=$(git rev-parse --git-dir 2>/dev/null) || { echo "❌ Git 저장소만 지원한다."; exit 1; }
5+
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 빌드 검증 시작..."
22+
if ! ./gradlew clean build --no-daemon; then
23+
echo "❌ 빌드 실패! 커밋 중단."
24+
exit 1
25+
else
26+
echo "✅ 빌드 성공! 커밋 계속."
27+
exit 0
28+
fi

.pre-commit-config.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

build-check.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

check-commit-message.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)