Skip to content

Commit

Permalink
support testing only on open PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mnich committed Oct 28, 2024
1 parent b436d91 commit 42dbc77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions modules/WingetMaintainerModule/Public/Test-ExistingPRs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@
function Test-ExistingPRs {
param(
[Parameter(Mandatory = $true)] [string] $Version,
[Parameter(Mandatory = $false)] [string] $PackageIdentifier = ${Env:PackageName}
[Parameter(Mandatory = $false)] [string] $PackageIdentifier = ${Env:PackageName},
[Parameter(Mandatory = $false)] [switch] $OnlyOpen
)
Write-Host "Checking for existing PRs for $PackageIdentifier $Version"
$ExistingOpenPRs = gh pr list --search "$($PackageIdentifier) $($Version) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json
if(!$OnlyOpen) {
$ExistingMergedPRs = gh pr list --search "$($PackageIdentifier) $($Version) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json
$ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs)
$ExistingPRs = @($ExistingOpenPRs) + @($ExistingMergedPRs)
}
else {
$ExistingPRs = @($ExistingOpenPRs)
}

if ($ExistingPRs.Count -gt 0) {
$ExistingPRs | ForEach-Object {
Expand Down
2 changes: 1 addition & 1 deletion scripts/Update-AllPackageManifests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function Update-WingetPackage {
$manifest = $manifestDict[$version]
# Extract the installer links from the manifest
$installerLinks = Export-InstallerLinks -Manifest $manifest
$prExists = Test-ExistingPRs -PackageIdentifier $PackageIdentifier -Version $version
$prExists = Test-ExistingPRs -PackageIdentifier $PackageIdentifier -Version $version -OnlyOpen
if(!$prExists || $Submit -eq $false) {
.\komac.exe update $PackageIdentifier --version $version --urls $installerLinks -o $OutputDir -t $Token ($Submit -eq $true ? '-s' : '--dry-run') ($resolves -match '^\d+$' ? "--resolves $resolves" : $null )
}
Expand Down

0 comments on commit 42dbc77

Please sign in to comment.