49 lines
1.4 KiB
PowerShell
49 lines
1.4 KiB
PowerShell
# 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
|
||
} |