Skip to content

Commit 4e52df4

Browse files
wkdgus1164claude
andcommitted
dev: Git pre-commit hook 추가 (자동 린트 검사)
추가된 파일: - scripts/hooks/pre-commit: ruff check 실행 훅 - scripts/setup-hooks.sh: 훅 설치 스크립트 기능: - 커밋 전 staged Python 파일에 대해 ruff check 자동 실행 - 린트 에러 발견 시 커밋 차단 - CI 실패 사전 방지 설치 방법: ```bash ./scripts/setup-hooks.sh ``` 우회 방법 (특별한 경우만): ```bash git commit --no-verify ``` Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 4d4e6e9 commit 4e52df4

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ git clone https://github.com/ureca-corp/document_parser.git
122122
cd document_parser
123123
uv sync --extra dev
124124

125+
# Git hooks 설치 (린트 자동 검사)
126+
./scripts/setup-hooks.sh
127+
125128
# 테스트 실행
126129
uv run pytest tests/ -v
127130

@@ -130,6 +133,21 @@ uv sync --extra docs
130133
uv run mkdocs serve
131134
```
132135

136+
### Git Hooks
137+
138+
프로젝트는 커밋 전 자동 린트 검사를 위한 Git hooks를 제공해요:
139+
140+
```bash
141+
# Hooks 설치
142+
./scripts/setup-hooks.sh
143+
144+
# 설치 후 커밋 시 자동으로 ruff check 실행
145+
git commit -m "message" # → 자동으로 린트 검사
146+
147+
# 필요시 우회 (권장하지 않음)
148+
git commit --no-verify -m "message"
149+
```
150+
133151
## 라이선스
134152

135153
MIT License - 자세한 내용은 [LICENSE](LICENSE) 파일을 참고하세요.

scripts/hooks/pre-commit

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Git pre-commit hook - Runs ruff check before allowing commit
3+
4+
echo "🔍 Running ruff check on staged Python files..."
5+
6+
# Get list of staged Python files
7+
PYTHON_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.pyi?$' || true)
8+
9+
if [ -z "$PYTHON_FILES" ]; then
10+
echo "✓ No Python files to check"
11+
exit 0
12+
fi
13+
14+
echo "Checking files:"
15+
echo "$PYTHON_FILES" | sed 's/^/ - /'
16+
17+
# Run ruff check on staged files
18+
if uv run ruff check $PYTHON_FILES; then
19+
echo "✓ Ruff check passed!"
20+
exit 0
21+
else
22+
echo ""
23+
echo "❌ Ruff check failed!"
24+
echo ""
25+
echo "Fix the errors above or:"
26+
echo " - Run: uv run ruff check --fix src/"
27+
echo " - Skip check: git commit --no-verify"
28+
exit 1
29+
fi

scripts/setup-hooks.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Setup script to install Git hooks
3+
4+
set -e
5+
6+
echo "🔧 Installing Git hooks..."
7+
8+
# Copy pre-commit hook
9+
cp scripts/hooks/pre-commit .git/hooks/pre-commit
10+
chmod +x .git/hooks/pre-commit
11+
12+
echo "✓ Pre-commit hook installed"
13+
echo ""
14+
echo "This hook will:"
15+
echo " - Run ruff check on staged Python files before commit"
16+
echo " - Block commits if lint errors are found"
17+
echo " - Skip with: git commit --no-verify (use sparingly!)"
18+
echo ""
19+
echo "🎉 Setup complete!"

0 commit comments

Comments
 (0)