From e778c85d6f24308f3d47ed10493f3b9944a24dcd Mon Sep 17 00:00:00 2001 From: travis plunk Date: Wed, 26 Apr 2023 11:08:19 -0700 Subject: [PATCH 1/4] Add prompt to fix conflicts --- tools/releaseTools.psm1 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/releaseTools.psm1 b/tools/releaseTools.psm1 index f156a8e1044..859b4939744 100644 --- a/tools/releaseTools.psm1 +++ b/tools/releaseTools.psm1 @@ -759,6 +759,23 @@ function Invoke-PRBackport { throw "$ScriptBlock fail with $LASTEXITCODE" } } + function script:Test-ShouldContinue { + param ( + $Message + ) + $continue = $false + while(!$continue) { + $input= Read-Host -Prompt ($Message + "`nType 'Yes' to continue 'No to exit") + switch($input) { + 'yes' { + $continue= $true + } + 'no' { + throw "User abort" + } + } + } + } $ErrorActionPreference = 'stop' $pr = gh pr view $PrNumber --json 'mergeCommit,state,title' | ConvertFrom-Json @@ -799,7 +816,12 @@ function Invoke-PRBackport { Invoke-NativeCommand { git switch upstream/$Target $switch $branchName } } + try { Invoke-NativeCommand { git cherry-pick $commitId } + } + catch { + Test-ShouldContinue -Message "Fix any conflicts with the cherry-pick." + } if ($PSCmdlet.ShouldProcess("Create the PR")) { gh pr create --base $Target --title $backportTitle --body "Backport #$PrNumber" From 745e6080656334fc1354d2cbf171a96b5458ec5f Mon Sep 17 00:00:00 2001 From: travis plunk Date: Wed, 26 Apr 2023 11:20:06 -0700 Subject: [PATCH 2/4] Add function to backport all approved PRs --- tools/releaseTools.psm1 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/releaseTools.psm1 b/tools/releaseTools.psm1 index 859b4939744..0c25b3e2705 100644 --- a/tools/releaseTools.psm1 +++ b/tools/releaseTools.psm1 @@ -817,7 +817,7 @@ function Invoke-PRBackport { } try { - Invoke-NativeCommand { git cherry-pick $commitId } + Invoke-NativeCommand { git cherry-pick $commitId } } catch { Test-ShouldContinue -Message "Fix any conflicts with the cherry-pick." @@ -828,4 +828,21 @@ function Invoke-PRBackport { } } -Export-ModuleMember -Function Get-ChangeLog, Get-NewOfficalPackage, Update-PsVersionInCode, Get-PRBackportReport, Invoke-PRBackport +function Invoke-PRBackportApproved { + param( + [Parameter(Mandatory)] + [semver] + $Version + ) + + $tagVersion = "$($Version.Major).$($Version.Minor)" + $target = "release/$ReleaseTag" + + Get-PRBackportReport -Version $tagVersion | + ForEach-Object { + $prNumber = $_.Number + Invoke-PRBackport -ErrorAction Stop -PrNumber $prNumber -Target $target + } +} + +Export-ModuleMember -Function Get-ChangeLog, Get-NewOfficalPackage, Update-PsVersionInCode, Get-PRBackportReport, Invoke-PRBackport, Invoke-PRBackportApproved From d15d90f7fea9934460aac76c85725fffd2b5a0bc Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 28 Apr 2023 10:51:52 -0700 Subject: [PATCH 3/4] Update tools/releaseTools.psm1 Co-authored-by: Dongbo Wang --- tools/releaseTools.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/releaseTools.psm1 b/tools/releaseTools.psm1 index 0c25b3e2705..149fa24c98a 100644 --- a/tools/releaseTools.psm1 +++ b/tools/releaseTools.psm1 @@ -765,7 +765,7 @@ function Invoke-PRBackport { ) $continue = $false while(!$continue) { - $input= Read-Host -Prompt ($Message + "`nType 'Yes' to continue 'No to exit") + $input= Read-Host -Prompt ($Message + "`nType 'Yes' to continue 'No' to exit") switch($input) { 'yes' { $continue= $true From fcf3fb6a97b7778ae74947c175bfa033f3b379c4 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 28 Apr 2023 10:52:01 -0700 Subject: [PATCH 4/4] Update tools/releaseTools.psm1 --- tools/releaseTools.psm1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/releaseTools.psm1 b/tools/releaseTools.psm1 index 149fa24c98a..3c222482348 100644 --- a/tools/releaseTools.psm1 +++ b/tools/releaseTools.psm1 @@ -828,6 +828,9 @@ function Invoke-PRBackport { } } +# Backport all approved backports +# Usage: +# Invoke-PRBackportApproved -Version 7.2.12 function Invoke-PRBackportApproved { param( [Parameter(Mandatory)]