[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.
[...]
```
This commit is contained in:
Rolf Bjarne Kvinge 2024-09-27 10:16:56 +02:00 коммит произвёл GitHub
Родитель 6df33a86bb
Коммит 852496d5de
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -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")