Skip to content

Commit

Permalink
Update retry logic in Verify and Merge scipt, Update Delete-RemoteBra… (
Browse files Browse the repository at this point in the history
#1160)

- Update retry logic in Verify and Merge scripts.
- Update Delete-RemoteBranches.ps1
  • Loading branch information
chidozieononiwu authored Nov 3, 2020
1 parent cf0a1cf commit 905086b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 3 additions & 1 deletion eng/common/scripts/Delete-RemoteBranches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ foreach ($branch in $branches)
exit 1
}

if ($pullRequests -and (($pullRequests | ? { $_.State -eq "open" }).Count -eq 0))
$openPullRequests = $pullRequests | ? { $_.State -eq "open" }

if ($openPullRequests.Count -eq 0)
{
LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated open Pull Request. Deleting Branch"
try{
Expand Down
15 changes: 3 additions & 12 deletions eng/common/scripts/git-branch-push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ param(
[string] $RemoteName = "azure-sdk-fork",

[Parameter(Mandatory = $false)]
[boolean] $SkipCommit = $false,

[Parameter(Mandatory = $false)]
[boolean] $AmendCommit = $false
[boolean] $SkipCommit = $false
)

# This is necessay because of the janky git command output writing to stderr.
Expand Down Expand Up @@ -69,14 +66,8 @@ if ($LASTEXITCODE -ne 0)
}

if (!$SkipCommit) {
if ($AmendCommit) {
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit -am `"$($CommitMsg)`""
git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit --amend -am "$($CommitMsg)"
}
else {
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit --amend -am `"$($CommitMsg)`""
git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit -am "$($CommitMsg)"
}
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit --amend -am `"$($CommitMsg)`""
git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit --amend -am "$($CommitMsg)"
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand Down
1 change: 0 additions & 1 deletion eng/pipelines/templates/steps/sync-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ steps:
-CommitMsg "${{ parameters.CommitMessage }}"
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/${{ repo }}.git"
-PushArgs "${{ parameters.PushArgs }}"
-AmendCommit $True
- task: PowerShell@2
displayName: Queue test pipeline
Expand Down
5 changes: 3 additions & 2 deletions eng/scripts/Verify-And-Merge-PRs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ do
exit 1
}
}
if ($unMergablePRs.Count -gt 0)

$RetryCount--
if (($unMergablePRs.Count -gt 0) -and ($RetryCount -gt 0) -and $ShouldMerge)
{
$PRData = $unMergablePRs
Start-Sleep -Seconds 30
$RetryCount--
LogDebug "Retrying merging for unmergable Prs"
$ReadyForMerge = $true
}
Expand Down

0 comments on commit 905086b

Please sign in to comment.