Skip to content

Commit 9811d74

Browse files
Fix push script passing in optional argument (Azure#19594)
With new PS command line parsing update in 7.3 they explicitly pass "" to the native commands which in our usage here we don't want. However setting the variable to null instead works for our scenario with both command line parsing strategies so using it here. Co-authored-by: Wes Haggard <[email protected]>
1 parent c76b028 commit 9811d74

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

eng/common/scripts/git-branch-push.ps1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if ((git remote) -contains $RemoteName)
5252
exit 1
5353
}
5454
}
55-
else
55+
else
5656
{
5757
Write-Host "git remote add $RemoteName $GitUrl"
5858
git remote add $RemoteName $GitUrl
@@ -66,8 +66,8 @@ else
6666
git show-ref --verify --quiet refs/heads/$PRBranchName
6767
if ($LASTEXITCODE -eq 0) {
6868
Write-Host "git checkout $PRBranchName."
69-
git checkout $PRBranchName
70-
}
69+
git checkout $PRBranchName
70+
}
7171
else {
7272
Write-Host "git checkout -b $PRBranchName."
7373
git checkout -b $PRBranchName
@@ -83,10 +83,11 @@ if (!$SkipCommit) {
8383
$amendOption = "--amend"
8484
}
8585
else {
86-
$amendOption = ""
86+
# Explicitly set this to null so that PS command line parser doesn't try to parse pass it as ""
87+
$amendOption = $null
8788
}
88-
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit $amendOption -am `"$($CommitMsg)`""
89-
git -c user.name="azure-sdk" -c user.email="[email protected]" commit $amendOption -am "$($CommitMsg)"
89+
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit $amendOption -am `"$CommitMsg`""
90+
git -c user.name="azure-sdk" -c user.email="[email protected]" commit $amendOption -am "$CommitMsg"
9091
if ($LASTEXITCODE -ne 0)
9192
{
9293
Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above."
@@ -115,7 +116,7 @@ do
115116
{
116117
$needsRetry = $true
117118
Write-Host "Git push failed with LASTEXITCODE=$($LASTEXITCODE) Need to fetch and rebase: attempt number=$($tryNumber)"
118-
119+
119120
Write-Host "git fetch $RemoteName $PRBranchName"
120121
# Full fetch will fail when the repo is in a sparse-checkout state, and single branch fetch is faster anyway.
121122
git fetch $RemoteName $PRBranchName
@@ -162,8 +163,8 @@ do
162163
continue
163164
}
164165

165-
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -m `"$($CommitMsg)`""
166-
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -m "$($CommitMsg)"
166+
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -m `"$CommitMsg`""
167+
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -m "$CommitMsg"
167168
if ($LASTEXITCODE -ne 0)
168169
{
169170
Write-Error "Unable to commit LASTEXITCODE=$($LASTEXITCODE), see command output above."
@@ -183,7 +184,7 @@ do
183184
if ($LASTEXITCODE -ne 0 -or $tryNumber -gt $numberOfRetries)
184185
{
185186
Write-Error "Unable to push commit after $($tryNumber) retries LASTEXITCODE=$($LASTEXITCODE), see command output above."
186-
if (0 -eq $LASTEXITCODE)
187+
if (0 -eq $LASTEXITCODE)
187188
{
188189
exit 1
189190
}

0 commit comments

Comments
 (0)