diff --git a/.cursorrules b/.cursorrules index 7484243..8bddb0a 100644 --- a/.cursorrules +++ b/.cursorrules @@ -28,6 +28,7 @@ g "작업 요약 내용" ``` 이 명령어는 `git add .`, `git commit -m "메시지"`, `git push`를 자동으로 실행합니다. +- `git push`는 실패 시 최대 2번까지 자동으로 재시도합니다. ### 주의사항 - 사용자가 명시적으로 요청하지 않는 한 실제로 git 명령어를 실행하지 마세요 diff --git a/git-auto.ps1 b/git-auto.ps1 index 87c7776..47e3cfd 100644 --- a/git-auto.ps1 +++ b/git-auto.ps1 @@ -34,15 +34,29 @@ function g { Write-Host "✅ git commit 완료" -ForegroundColor Green Write-Host "" - # 3. git push - Write-Host "▶ git push 실행 중..." -ForegroundColor Yellow - git push - if ($LASTEXITCODE -ne 0) { - Write-Host "❌ git push 실패" -ForegroundColor Red - Write-Host " (원격 저장소 설정을 확인하세요)" -ForegroundColor Yellow - return + # 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 "✅ git push 완료" -ForegroundColor Green Write-Host "" Write-Host "========================================" -ForegroundColor Cyan