Files
ProjectMD/git-hooks/pre-commit.ps1

49 lines
1.4 KiB
PowerShell
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# git-hooks/pre-commit.ps1
Write-Host "🔍 Pre-commit: Validating game data..." -ForegroundColor Cyan
# 변경된 CSV 파일 확인
$changedFiles = git diff --cached --name-only --diff-filter=ACM
$CSVFiles = $changedFiles | Where-Object { $_ -match "GameData/.*\.csv$" }
if ($CSVFiles.Count -eq 0) {
Write-Host " 변경된 CSV 파일이 없습니다." -ForegroundColor Gray
exit 0
}
Write-Host "📊 검증할 파일:" -ForegroundColor Yellow
$CSVFiles | ForEach-Object { Write-Host " - $_" }
Write-Host ""
# Python 설치 확인
$pythonCmd = Get-Command python -ErrorAction SilentlyContinue
if (-not $pythonCmd) {
Write-Host "❌ Python이 설치되어 있지 않습니다." -ForegroundColor Red
Write-Host "💡 https://www.python.org/downloads/ 에서 Python을 설치하세요." -ForegroundColor Yellow
exit 1
}
# 검증 스크립트 실행
Push-Location DataTools
try {
python validate_data.py
$exitCode = $LASTEXITCODE
Pop-Location
if ($exitCode -ne 0) {
Write-Host ""
Write-Host "❌ 데이터 검증 실패!" -ForegroundColor Red
Write-Host "💡 CSV 파일을 수정 후 다시 커밋해주세요." -ForegroundColor Yellow
exit 1
}
Write-Host "✅ 데이터 검증 통과!" -ForegroundColor Green
exit 0
}
catch {
Pop-Location
Write-Host "❌ 검증 중 오류 발생: $_" -ForegroundColor Red
exit 1
}