From 7e230c35c11fd3d2a01079b189a313b17e514c7b Mon Sep 17 00:00:00 2001 From: uday31in <14359777+uday31in@users.noreply.github.com> Date: Sat, 1 Aug 2020 01:49:43 +0100 Subject: [PATCH] adding condition on while loop --- src/public/Invoke-AzOpsGitPull.ps1 | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/public/Invoke-AzOpsGitPull.ps1 b/src/public/Invoke-AzOpsGitPull.ps1 index a570d603..6d0d92b3 100644 --- a/src/public/Invoke-AzOpsGitPull.ps1 +++ b/src/public/Invoke-AzOpsGitPull.ps1 @@ -136,9 +136,10 @@ function Invoke-AzOpsGitPull { Write-AzOpsLog -Level Information -Topic "gh" -Message "Merging new pull request" $attempt = 1 - $retryCount = 3 + $retryCount = 6 $unmerged = $true do { + $attempt = $attempt + 1 try { Start-AzOpsNativeExecution { gh pr merge $response[0].number --squash --delete-branch -R $global:GitHubRepository @@ -146,17 +147,11 @@ function Invoke-AzOpsGitPull { $unmerged = $false } catch { - if ($attempt -gt $retryCount) { - $unmerged = $true - } - else { - Write-AzOpsLog -Level Warning -Topic "gh" -Message "Retrying pull request merge" - Start-Sleep -Seconds 5 - $attempt = $attempt + 1 - } + Write-AzOpsLog -Level Warning -Topic "gh" -Message "Retrying pull request merge, attempt $attempt" + Start-Sleep -Seconds 5 } } - while ($unmerged) + while ($unmerged -and ($attempt -lt $retryCount)) if ($unmerged -eq $true) { $params = @{