From 852496d5de668837be2bd5483553293a2df299bd Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 27 Sep 2024 10:16:56 +0200 Subject: [PATCH] [devops] Only fetch the exact remote branches we need to undo the GitHub merge. (#21266) This will typically save between 1 and 2 minutes for every test run. But potentially much more if GitHub happens to be slow: ``` [...] Working on a PR, Undoing the github merge with main. ##[error]The task has timed out. [...] ``` --- tools/devops/automation/scripts/undo_github_merge.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/devops/automation/scripts/undo_github_merge.ps1 b/tools/devops/automation/scripts/undo_github_merge.ps1 index 32befd505352..af8e54f627a9 100644 --- a/tools/devops/automation/scripts/undo_github_merge.ps1 +++ b/tools/devops/automation/scripts/undo_github_merge.ps1 @@ -11,8 +11,11 @@ param if($IsPr.ToLower() -eq "true") { Write-Host "Working on a PR, Undoing the github merge with main." - git config remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*' - git fetch origin + $refspec="+refs/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*:refs/remotes/origin/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*" + + Write-Host "Refspec: $refspec" + + git fetch origin "$refspec" $branch="$SourceBranch".Replace("merge", "head") $branch=$branch.Replace("refs", "origin")