-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b1e235
commit fc1c6ed
Showing
5 changed files
with
107 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,25 +27,33 @@ param( | |
[Parameter(Mandatory = $false)] | ||
[string] $PushArgs = "", | ||
|
||
[string] $RemoteName = "azure-sdk-fork", | ||
|
||
[Parameter(Mandatory = $false)] | ||
[boolean] $SkipCommit = $false, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[boolean] $SkipCommit = $false | ||
[boolean] $AmendCommit = $false | ||
) | ||
|
||
# This is necessay because of the janky git command output writing to stderr. | ||
# Without explicitly setting the ErrorActionPreference to continue the script | ||
# would fail the first time git wrote command output. | ||
$ErrorActionPreference = "Continue" | ||
|
||
Write-Host "git remote add azure-sdk-fork $GitUrl" | ||
git remote add azure-sdk-fork $GitUrl | ||
if ($LASTEXITCODE -ne 0) | ||
if (!(git remote | ? {$_ -eq $RemoteName})) | ||
{ | ||
Write-Error "Unable to add remote LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
exit $LASTEXITCODE | ||
Write-Host "git remote add $RemoteName $GitUrl" | ||
git remote add $RemoteName $GitUrl | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to add remote LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
exit $LASTEXITCODE | ||
} | ||
} | ||
|
||
Write-Host "git fetch azure-sdk-fork" | ||
git fetch azure-sdk-fork | ||
Write-Host "git fetch $RemoteName" | ||
git fetch $RemoteName | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
|
@@ -61,8 +69,14 @@ if ($LASTEXITCODE -ne 0) | |
} | ||
|
||
if (!$SkipCommit) { | ||
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -am `"$($CommitMsg)`"" | ||
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -am "$($CommitMsg)" | ||
if ($AmendCommit) { | ||
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -am `"$($CommitMsg)`"" | ||
git -c user.name="azure-sdk" -c user.email="[email protected]" commit --amend -am "$($CommitMsg)" | ||
} | ||
else { | ||
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit --amend -am `"$($CommitMsg)`"" | ||
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -am "$($CommitMsg)" | ||
} | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
|
@@ -84,15 +98,15 @@ $tryNumber = 0 | |
do | ||
{ | ||
$needsRetry = $false | ||
Write-Host "git push azure-sdk-fork $PRBranchName $PushArgs" | ||
git push azure-sdk-fork $PRBranchName $PushArgs | ||
Write-Host "git push $RemoteName $PRBranchName $PushArgs" | ||
git push $RemoteName $PRBranchName $PushArgs | ||
$tryNumber++ | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
$needsRetry = $true | ||
Write-Host "Git push failed with LASTEXITCODE=$($LASTEXITCODE) Need to fetch and rebase: attempt number=$($tryNumber)" | ||
Write-Host "git fetch azure-sdk-fork" | ||
git fetch azure-sdk-fork | ||
Write-Host "git fetch $RemoteName" | ||
git fetch $RemoteName | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to fetch remote LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
|
@@ -110,8 +124,8 @@ do | |
continue | ||
} | ||
|
||
Write-Host "git reset --hard azure-sdk-fork/${PRBranchName}" | ||
git reset --hard azure-sdk-fork/${PRBranchName} | ||
Write-Host "git reset --hard $RemoteName/${PRBranchName}" | ||
git reset --hard $RemoteName/${PRBranchName} | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to hard reset branch LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
|
@@ -127,6 +141,7 @@ do | |
exit $LASTEXITCODE | ||
} | ||
|
||
|
||
Write-Host "git add -A" | ||
git add -A | ||
if ($LASTEXITCODE -ne 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters