From f70c31b501082be4459b139d0f5ee8706bbeb7a6 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 19 Sep 2024 11:48:17 +0200 Subject: [PATCH 1/4] [devops] Only fetch the exact remote branches we need to undo the GitHub merge. This should save between 1 and 2 minutes for every test run (and potentially much more if GitHub happens to be slow). --- tools/devops/automation/scripts/undo_github_merge.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/scripts/undo_github_merge.ps1 b/tools/devops/automation/scripts/undo_github_merge.ps1 index 32befd505352..d6ffe0b5cc69 100644 --- a/tools/devops/automation/scripts/undo_github_merge.ps1 +++ b/tools/devops/automation/scripts/undo_github_merge.ps1 @@ -11,7 +11,7 @@ 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 config remote.origin.fetch '+refs/pull/$($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)/*:refs/remotes/origin/pull/$($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)/*' git fetch origin $branch="$SourceBranch".Replace("merge", "head") From 630f639706cfd5a07c092483e9716370968fb070 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 19 Sep 2024 13:45:03 +0200 Subject: [PATCH 2/4] Does this work? --- tools/devops/automation/scripts/undo_github_merge.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/scripts/undo_github_merge.ps1 b/tools/devops/automation/scripts/undo_github_merge.ps1 index d6ffe0b5cc69..ac08f88f9bc5 100644 --- a/tools/devops/automation/scripts/undo_github_merge.ps1 +++ b/tools/devops/automation/scripts/undo_github_merge.ps1 @@ -11,7 +11,7 @@ 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/$($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)/*:refs/remotes/origin/pull/$($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)/*' + git config remote.origin.fetch '+refs/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*:refs/remotes/origin/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*' git fetch origin $branch="$SourceBranch".Replace("merge", "head") From 5fe11ef4f7453b0fe05ea8c5f749192cbba9b0ef Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 19 Sep 2024 15:52:20 +0200 Subject: [PATCH 3/4] quotes! --- tools/devops/automation/scripts/undo_github_merge.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/devops/automation/scripts/undo_github_merge.ps1 b/tools/devops/automation/scripts/undo_github_merge.ps1 index ac08f88f9bc5..263ede7f6fc8 100644 --- a/tools/devops/automation/scripts/undo_github_merge.ps1 +++ b/tools/devops/automation/scripts/undo_github_merge.ps1 @@ -11,7 +11,7 @@ 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/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*:refs/remotes/origin/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*' + git config remote.origin.fetch "+refs/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*:refs/remotes/origin/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*" git fetch origin $branch="$SourceBranch".Replace("merge", "head") From cfbf9ba8f17a82218982abd22c0c26ac2b5ffee6 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 19 Sep 2024 15:54:50 +0200 Subject: [PATCH 4/4] don't store the refspec in the git config file --- 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 263ede7f6fc8..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/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*:refs/remotes/origin/pull/$Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/*" - 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")