Skip to content

Commit 2ba49ac

Browse files
Only delete branches if initial setup was executed
1 parent bc7ae86 commit 2ba49ac

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

check.ps1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,21 @@ foreach ($version in $lastFewVersions) {
210210
Invoke-NativeCommand gh pr create --title "$title" --body "$body" --repo microsoft/winget-pkgs --base master --head Rust-Winget-Bot:rust-$version-$toolchainLower
211211
}
212212
}
213-
$closedPRs = Invoke-NativeCommand gh pr list --author "Rust-Winget-Bot" --repo "microsoft/winget-pkgs" --state=closed --limit 10
214-
| Foreach-Object {((($_ -split '\t')[2]) -split ':')[1]};
213+
if ($initialSetupExecuted) {
214+
$closedPRs = Invoke-NativeCommand gh pr list --author "Rust-Winget-Bot" --repo "microsoft/winget-pkgs" --state=closed --limit 10
215+
| Foreach-Object {((($_ -split '\t')[2]) -split ':')[1]};
215216

216-
$branches = Invoke-NativeCommand git ls-remote --heads https://github.com/Rust-Winget-Bot/winget-pkgs.git
217-
| Select-String -Pattern "refs/heads/(.+$)"
218-
| ForEach-Object { $_.Matches[0].Groups[1].Value }
217+
$branches = Invoke-NativeCommand git ls-remote --heads https://github.com/Rust-Winget-Bot/winget-pkgs.git
218+
| Select-String -Pattern "refs/heads/(.+$)"
219+
| ForEach-Object { $_.Matches[0].Groups[1].Value }
219220

220-
foreach ($pr in $closedPRs) {
221-
if ($branches.Contains($pr)) {
222-
Invoke-NativeCommand git push https://github.com/Rust-Winget-Bot/winget-pkgs.git -d $pr
221+
foreach ($pr in $closedPRs) {
222+
if ($branches.Contains($pr)) {
223+
Invoke-NativeCommand git push origin -d $pr
224+
}
223225
}
224226
}
225227

226228

229+
230+

0 commit comments

Comments
 (0)