mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Add retry command function to retry git push for final asm.
This commit is contained in:
parent
0978c7bcf5
commit
840f1be8c6
@ -1,9 +1,29 @@
|
|||||||
# Include the API access functions
|
# Include the API access functions
|
||||||
. $PSScriptRoot\API-Functions.ps1
|
. $PSScriptRoot\API-Functions.ps1
|
||||||
|
|
||||||
|
function Run-Command-With-Retry {
|
||||||
|
param(
|
||||||
|
[string]$cmd,
|
||||||
|
[string]$cleanup_cmd = "",
|
||||||
|
[int]$maxTries = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
while ($maxTries -gt 0) {
|
||||||
|
cmd.exe /c $cmd
|
||||||
|
if($?){
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
cmd.exe /c $cleanup_cmd
|
||||||
|
$maxTries = $maxTries - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw "Command $($command) failed with exit code $($LastExitCode)"
|
||||||
|
}
|
||||||
|
|
||||||
function collectAsm {
|
function collectAsm {
|
||||||
cmd.exe /c "git checkout $($env:APPVEYOR_REPO_BRANCH) 2>&1"
|
cmd.exe /c "git checkout $($env:APPVEYOR_REPO_BRANCH) 2>&1"
|
||||||
git fetch --all 2>&1
|
cmd.exe /c "git fetch --all 2>&1"
|
||||||
|
|
||||||
# Create branch to merge asm into
|
# Create branch to merge asm into
|
||||||
$asmFinalBranch = "asm/$($env:APPVEYOR_REPO_COMMIT)/final"
|
$asmFinalBranch = "asm/$($env:APPVEYOR_REPO_COMMIT)/final"
|
||||||
@ -14,7 +34,7 @@ function collectAsm {
|
|||||||
$branchName = "asm/$($env:APPVEYOR_REPO_COMMIT)/appveyor-$($_.jobId)"
|
$branchName = "asm/$($env:APPVEYOR_REPO_COMMIT)/appveyor-$($_.jobId)"
|
||||||
|
|
||||||
#Check that all branches exist
|
#Check that all branches exist
|
||||||
git ls-remote --heads --exit-code https://github.com/dadonenf/GSL.git $branchName
|
cmd.exe /c "git ls-remote --heads --exit-code https://github.com/dadonenf/GSL.git $($branchName)"
|
||||||
if(-not $?){
|
if(-not $?){
|
||||||
throw "Missing branch for job $($_.jobId)"
|
throw "Missing branch for job $($_.jobId)"
|
||||||
}
|
}
|
||||||
@ -36,10 +56,10 @@ function collectAsm {
|
|||||||
if(-not $?){
|
if(-not $?){
|
||||||
throw "Failed merge"
|
throw "Failed merge"
|
||||||
}
|
}
|
||||||
git diff-index --cached --quiet --exit-code HEAD
|
cmd.exe /c "git diff-index --cached --quiet --exit-code HEAD"
|
||||||
if(-not $?) {
|
if(-not $?) {
|
||||||
git commit -m "[skip ci] Update ASM for $($env:APPVEYOR_REPO_COMMIT)"
|
git commit -m "[skip ci] Update ASM for $($env:APPVEYOR_REPO_COMMIT)"
|
||||||
cmd.exe /c "git push 2>&1"
|
Run-Command-With-Retry -cmd "git push 2>&1" -cleanup_cmd "git pull --rebase 2>&1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user