🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
67 lines
2.4 KiB
PowerShell
67 lines
2.4 KiB
PowerShell
# Git 자동화 스크립트
|
|
# 사용법: g "커밋 메시지"
|
|
|
|
function g {
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$message
|
|
)
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Git 자동화 시작" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# 1. git add .
|
|
Write-Host "▶ git add . 실행 중..." -ForegroundColor Yellow
|
|
git add .
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "❌ git add 실패" -ForegroundColor Red
|
|
return
|
|
}
|
|
Write-Host "✅ git add 완료" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# 2. git commit
|
|
Write-Host "▶ git commit 실행 중..." -ForegroundColor Yellow
|
|
Write-Host " 메시지: $message" -ForegroundColor Gray
|
|
git commit -m "$message"
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "❌ git commit 실패" -ForegroundColor Red
|
|
Write-Host " (변경사항이 없거나 이미 커밋된 상태일 수 있습니다)" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
Write-Host "✅ git commit 완료" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# 3. git push (최대 2번 재시도)
|
|
$pushAttempt = 0
|
|
$maxPushAttempts = 2
|
|
$pushSuccess = $false
|
|
|
|
while ($pushAttempt -lt $maxPushAttempts -and -not $pushSuccess) {
|
|
$pushAttempt++
|
|
Write-Host "▶ git push 실행 중... (시도 $pushAttempt/$maxPushAttempts)" -ForegroundColor Yellow
|
|
git push
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "✅ git push 완료" -ForegroundColor Green
|
|
$pushSuccess = $true
|
|
} else {
|
|
if ($pushAttempt -lt $maxPushAttempts) {
|
|
Write-Host "⚠️ git push 실패, 재시도 중... ($pushAttempt/$maxPushAttempts)" -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 2
|
|
} else {
|
|
Write-Host "❌ git push 실패 (최대 재시도 횟수 도달)" -ForegroundColor Red
|
|
Write-Host " (원격 저장소 설정을 확인하세요)" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
}
|
|
}
|
|
Write-Host ""
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "✅ 모든 작업 완료!" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
}
|
|
|