Skip to content

Instantly share code, notes, and snippets.

@jedieaston
Last active April 18, 2021 19:03
Show Gist options
  • Save jedieaston/8cd3a965158f221e53c6da4e163b5a75 to your computer and use it in GitHub Desktop.
Save jedieaston/8cd3a965158f221e53c6da4e163b5a75 to your computer and use it in GitHub Desktop.
Script to remove a bunch of manifests from winget-pkgs.
$ErrorActionPreference = "Stop"
$FirefoxRoot = "C:\Users\Easton Pillay\projects\winget-pkgs\manifests\m\Mozilla\Firefox\Firefox\"
$PATH_TO_PR_BODY = "C:\Users\Easton Pillay\projects\qprbody.md"
$committedBranches = @()
Set-Location $FirefoxRoot
git checkout master
git remote add upstream https://github.com/microsoft/winget-pkgs/
git fetch --all
$versions = Get-ChildItem -Directory | Select-Object Name
foreach($i in $versions) {
Set-Location $FirefoxRoot
$i = $i.Name
$deleteBranchName = "Firefox-" + ($i -replace '\s','') + '-DELETE'
Write-Host 'Starting version ' + $i -ForegroundColor Yellow
git checkout -b $deleteBranchName upstream/master
if($LASTEXITCODE -ne 0) {
Write-Host 'Skipping ' + $i -ForegroundColor Yellow
continue;
}
git rm -r $i
git commit -m ("Removed duplicate manifest for Firefox version " + $i + ".")
if ($LASTEXITCODE -eq 0) {
$committedBranches += $deleteBranchName
}
git checkout main
Write-Host "Completed version $i." -ForegroundColor Green
}
Write-Host 'All done with the writes.' $committedBranches.Length 'were created. ' -ForegroundColor Green
Write-Host "Press enter to begin opening pull requests." -ForegroundColor Yellow
pause
foreach ($i in $committedBranches) {
git checkout $i
git push -u origin
gh pr create --body-file -f
Write-Host "Waiting so we don't DDOS GitHub..." -ForegroundColor Red
Start-Sleep -Seconds 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment