From c50ed33241256df7d420b1db0aa1da1ad3cfc27b Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 4 Nov 2020 17:50:46 -0800 Subject: [PATCH] Fix bug in git branch push (#17188) Co-authored-by: Chidozie Ononiwu --- eng/common/scripts/git-branch-push.ps1 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/git-branch-push.ps1 b/eng/common/scripts/git-branch-push.ps1 index 63abfa3715101..72c0df0f6b63e 100644 --- a/eng/common/scripts/git-branch-push.ps1 +++ b/eng/common/scripts/git-branch-push.ps1 @@ -30,7 +30,10 @@ param( [string] $RemoteName = "azure-sdk-fork", [Parameter(Mandatory = $false)] - [boolean] $SkipCommit = $false + [boolean] $SkipCommit = $false, + + [Parameter(Mandatory = $false)] + [boolean] $AmendCommit = $false ) # This is necessay because of the janky git command output writing to stderr. @@ -66,8 +69,14 @@ if ($LASTEXITCODE -ne 0) } if (!$SkipCommit) { - Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit --amend -am `"$($CommitMsg)`"" - git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit --amend -am "$($CommitMsg)" + if ($AmendCommit) { + $amendOption = "--amend" + } + else { + $amendOption = "" + } + Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit $amendOption -am `"$($CommitMsg)`"" + git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit $amendOption -am "$($CommitMsg)" if ($LASTEXITCODE -ne 0) { Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above."