From ecdb447493d4184a5518d068c20dfddfcb1bb8b3 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 7 Jul 2021 11:06:45 +0200 Subject: [PATCH] Fix cherry-picker.ps1 --- Scripts/cherry-picker.ps1 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Scripts/cherry-picker.ps1 b/Scripts/cherry-picker.ps1 index b87d1002..83205f07 100755 --- a/Scripts/cherry-picker.ps1 +++ b/Scripts/cherry-picker.ps1 @@ -9,38 +9,40 @@ param($CommitID = "", $CommitMessage = "", $Branches = "", $RepoDir = "$PWD") if ($CommitID -eq "" ) { $CommitID = read-host "Enter the commit id to cherry-pick" } if ($CommitMessage -eq "" ) { $CommitMessage = read-host "Enter the commit message to use" } -if ($Branches -eq "" ) { $Branches = read-host "Enter the target branches" } +if ($Branches -eq "" ) { $Branches = read-host "Enter the target branches separated by spaces" } try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } set-location "$RepoDir" + $Branches = $Branches.Split(' ') foreach($Branch in $Branches) { - "STEP: Switching to branch $Branch (git checkout)..." + "Switching to branch $Branch (git checkout)..." & git checkout --recurse-submodules --force $Branch if ($lastExitCode -ne "0") { throw "'git checkout' failed" } - "STEP: Updating submodules (git submodule update)..." + "Updating submodules (git submodule update)..." & git submodule update --init --recursive if ($lastExitCode -ne "0") { throw "'git submodule update' failed" } - "STEP: Cleaning the repository (git clean -fdx)..." - & git clean -fdx - if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" } + "Cleaning the repository (git clean -fdx)..." + & git clean -fdx -f + if ($lastExitCode -ne "0") { throw "'git clean' failed" } - & git submodule foreach --recursive git clean -fdx - if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" } + & git submodule foreach --recursive git clean -fdx -f + if ($lastExitCode -ne "0") { throw "'git clean' in submodules failed" } - "STEP: Pulling latest updates (git pull)..." + "Pulling latest updates (git pull)..." & git pull --recurse-submodules if ($lastExitCode -ne "0") { throw "'git pull' failed" } - "STEP: Checking the status (git status)..." + "Checking the status (git status)..." $Result = (git status) if ($lastExitCode -ne "0") { throw "'git status' failed" } if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Branch is NOT clean: $Result" } + "Cherry-picking and committing..." & git cherry-pick --no-commit "$CommitID" if ($lastExitCode -ne "0") { throw "'git cherry-pick $CommitID' failed" }