Skip to content

Commit

Permalink
Check remote refs instead of local refs when applying/pushing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp authored and azure-sdk committed Jun 1, 2021
1 parent a0c60af commit 4b9dbe3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions eng/common/scripts/git-branch-push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ else
}
}
# Checkout to $PRBranch, create new one if not exists.
git show-ref --verify --quiet refs/heads/$PRBranchName
git ls-remote --exit-code --heads $RemoteName $PRBranchName
if ($LASTEXITCODE -eq 0) {
Write-Host "git fetch $RemoteName $PRBranchName"
git fetch $RemoteName $PRBranchName
Write-Host "git checkout $PRBranchName."
git checkout $PRBranchName
}
Expand Down Expand Up @@ -116,8 +118,8 @@ do
$needsRetry = $true
Write-Host "Git push failed with LASTEXITCODE=$($LASTEXITCODE) Need to fetch and rebase: attempt number=$($tryNumber)"

Write-Host "git fetch $RemoteName"
git fetch $RemoteName
Write-Host "git fetch $RemoteName $PRBranchName"
git fetch $RemoteName $PRBranchName
if ($LASTEXITCODE -ne 0)
{
Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above."
Expand Down

0 comments on commit 4b9dbe3

Please sign in to comment.