@@ -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
6666git show-ref -- verify -- quiet refs/ heads/ $PRBranchName
6767if ($LASTEXITCODE -eq 0 ) {
6868 Write-Host " git checkout $PRBranchName ."
69- git checkout $PRBranchName
70- }
69+ git checkout $PRBranchName
70+ }
7171else {
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=`" azuresdk@microsoft.com`" commit $amendOption -am `" $ ( $ CommitMsg) `" "
89- git - c user.name= " azure-sdk" - c user.email= " azuresdk@microsoft.com" commit $amendOption - am " $ ( $ CommitMsg) "
89+ Write-Host " git -c user.name=`" azure-sdk`" -c user.email=`" azuresdk@microsoft.com`" commit $amendOption -am `" $CommitMsg `" "
90+ git - c user.name= " azure-sdk" - c user.email= " azuresdk@microsoft.com" 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."
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
162163 continue
163164 }
164165
165- Write-Host " git -c user.name=`" azure-sdk`" -c user.email=`" azuresdk@microsoft.com`" commit -m `" $ ( $ CommitMsg) `" "
166- git - c user.name= " azure-sdk" - c user.email= " azuresdk@microsoft.com" commit - m " $ ( $ CommitMsg) "
166+ Write-Host " git -c user.name=`" azure-sdk`" -c user.email=`" azuresdk@microsoft.com`" commit -m `" $CommitMsg `" "
167+ git - c user.name= " azure-sdk" - c user.email= " azuresdk@microsoft.com" commit - m " $CommitMsg "
167168 if ($LASTEXITCODE -ne 0 )
168169 {
169170 Write-Error " Unable to commit LASTEXITCODE=$ ( $LASTEXITCODE ) , see command output above."
183184if ($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