Skip to content

Commit aae4fc6

Browse files
authored
Merge pull request #10 from EntryDSM/feature/9-pre-commit-setting
Feature/9 pre commit setting
2 parents c70c321 + 18b715f commit aae4fc6

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: build-check
5+
name: 빌드 검증
6+
entry: ./build-check.sh
7+
language: script
8+
pass_filenames: false
9+
10+
- id: commit-msg-check
11+
name: 커밋 메시지 포맷 검증
12+
entry: ./check-commit-message.sh
13+
language: script
14+
stages: [ commit-msg ]

build-check.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
cd "$(git rev-parse --show-toplevel)" || exit 1
4+
5+
echo "Gradle 빌드 검증 시작..."
6+
7+
./gradlew clean build --no-daemon
8+
BUILD_RESULT=$?
9+
10+
if [ $BUILD_RESULT -ne 0 ]; then
11+
echo "❌ 빌드 실패! 커밋이 중단됩니다."
12+
exit 1
13+
else
14+
echo "✅ 빌드 성공! 커밋 계속 진행합니다."
15+
exit 0
16+
fi

check-commit-message.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
commit_msg=$(cat "$1")
4+
5+
regex="^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) \([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) : .+$"
6+
7+
if [[ "$commit_msg" =~ $regex ]]; then
8+
echo "✅ 커밋 메시지 형식이 올바릅니다."
9+
exit 0
10+
else
11+
echo "❌ 커밋 메시지 형식이 잘못되었습니다."
12+
exit 1
13+
fi

0 commit comments

Comments
 (0)