From c783834393ed7993a6c7ed3ac8d4efc8f284a133 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 28 Oct 2020 19:56:37 -0700 Subject: [PATCH] Uses different commit SHA instead --- eng/common/scripts/git-branch-push.ps1 | 38 +++++++++++++------ .../scripts/modules/ChangeLog-Operations.psm1 | 1 - 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/eng/common/scripts/git-branch-push.ps1 b/eng/common/scripts/git-branch-push.ps1 index 333ed0a62c..c214cdbb5c 100644 --- a/eng/common/scripts/git-branch-push.ps1 +++ b/eng/common/scripts/git-branch-push.ps1 @@ -27,8 +27,13 @@ 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. @@ -36,16 +41,16 @@ param( # 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 +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." @@ -60,6 +65,16 @@ if ($LASTEXITCODE -ne 0) exit $LASTEXITCODE } +if ($SkipCommit -and $AmendCommit) { + Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit --amend -m `"$($CommitMsg)`"" + git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit --amend -m "$($CommitMsg)" + if ($LASTEXITCODE -ne 0) + { + Write-Error "Unable to ammend commit message LASTEXITCODE=$($LASTEXITCODE), see command output above." + exit $LASTEXITCODE + } +} + if (!$SkipCommit) { Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"azuresdk@microsoft.com`" commit -am `"$($CommitMsg)`"" git -c user.name="azure-sdk" -c user.email="azuresdk@microsoft.com" commit -am "$($CommitMsg)" @@ -84,15 +99,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 +125,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 +142,7 @@ do exit $LASTEXITCODE } + Write-Host "git add -A" git add -A if ($LASTEXITCODE -ne 0) diff --git a/eng/common/scripts/modules/ChangeLog-Operations.psm1 b/eng/common/scripts/modules/ChangeLog-Operations.psm1 index ca432870b3..cba8a26312 100644 --- a/eng/common/scripts/modules/ChangeLog-Operations.psm1 +++ b/eng/common/scripts/modules/ChangeLog-Operations.psm1 @@ -1,6 +1,5 @@ $RELEASE_TITLE_REGEX = "(?^\#+.*(?\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s(?\(Unreleased\)|\(\d{4}-\d{2}-\d{2}\)))?)" -# Returns a Collection of changeLogEntry object containing changelog info for all version present in the gived CHANGELOG function Get-ChangeLogEntries { param ( [Parameter(Mandatory = $true)]