Skip to content

Commit f00d4b6

Browse files
committed
Fix 2>&1 stderr corruption in gh search, prefix-match SHA comparison in CheckMissing
1 parent 57559cd commit f00d4b6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

.github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ if ($CheckMissing) {
120120
Write-Section "Checking for missing backflow PRs in $Repository"
121121

122122
# Find open backflow PRs (to know which branches are already covered)
123-
$openPRsJson = gh search prs --repo $Repository --author "dotnet-maestro[bot]" --state open "Source code updates from dotnet/dotnet" --json number,title --limit 50 2>&1
123+
$openPRsJson = gh search prs --repo $Repository --author "dotnet-maestro[bot]" --state open "Source code updates from dotnet/dotnet" --json number,title --limit 50 2>$null
124124
$openPRs = @()
125125
if ($LASTEXITCODE -eq 0 -and $openPRsJson) {
126-
$openPRs = ($openPRsJson -join "`n") | ConvertFrom-Json
126+
try { $openPRs = ($openPRsJson -join "`n") | ConvertFrom-Json } catch { $openPRs = @() }
127127
}
128128
$openBranches = @{}
129129
foreach ($opr in $openPRs) {
@@ -141,10 +141,10 @@ if ($CheckMissing) {
141141
}
142142

143143
# Find recently merged backflow PRs to discover branches and VMR commit mapping
144-
$mergedPRsJson = gh search prs --repo $Repository --author "dotnet-maestro[bot]" --state closed --merged "Source code updates from dotnet/dotnet" --limit 30 --sort updated --json number,title,closedAt 2>&1
144+
$mergedPRsJson = gh search prs --repo $Repository --author "dotnet-maestro[bot]" --state closed --merged "Source code updates from dotnet/dotnet" --limit 30 --sort updated --json number,title,closedAt 2>$null
145145
$mergedPRs = @()
146146
if ($LASTEXITCODE -eq 0 -and $mergedPRsJson) {
147-
$mergedPRs = ($mergedPRsJson -join "`n") | ConvertFrom-Json
147+
try { $mergedPRs = ($mergedPRsJson -join "`n") | ConvertFrom-Json } catch { $mergedPRs = @() }
148148
}
149149

150150
if ($mergedPRs.Count -eq 0 -and $openPRs.Count -eq 0) {
@@ -222,7 +222,7 @@ if ($CheckMissing) {
222222
$vmrHeadSha = $vmrHead.sha
223223
$vmrHeadDate = $vmrHead.commit.committer.date
224224

225-
if ($vmrCommitFromPR -eq $vmrHeadSha) {
225+
if ($vmrCommitFromPR -eq $vmrHeadSha -or $vmrHeadSha.StartsWith($vmrCommitFromPR) -or $vmrCommitFromPR.StartsWith($vmrHeadSha)) {
226226
Write-Host " ✅ VMR branch is at same commit — no backflow needed" -ForegroundColor Green
227227
$upToDateCount++
228228
}
@@ -559,14 +559,19 @@ if ($vmrCommit -and $vmrBranch) {
559559

560560
# --- For backflow PRs that are behind: check pending forward flow PRs ---
561561
if ($isBackflow -and $compareStatus -eq 'ahead' -and $aheadBy -gt 0 -and $vmrBranch) {
562-
$forwardPRsJson = gh search prs --repo dotnet/dotnet --author "dotnet-maestro[bot]" --state open "Source code updates from" --base $vmrBranch --json number,title --limit 20 2>&1
562+
$forwardPRsJson = gh search prs --repo dotnet/dotnet --author "dotnet-maestro[bot]" --state open "Source code updates from" --base $vmrBranch --json number,title --limit 20 2>$null
563563
$pendingForwardPRs = @()
564564
if ($LASTEXITCODE -eq 0 -and $forwardPRsJson) {
565-
$allForward = ($forwardPRsJson -join "`n") | ConvertFrom-Json
566-
# Filter to forward flow PRs (not backflow) targeting this VMR branch
567-
$pendingForwardPRs = $allForward | Where-Object {
568-
$_.title -match "Source code updates from (dotnet/\S+)" -and
569-
$Matches[1] -ne "dotnet/dotnet"
565+
try {
566+
$allForward = ($forwardPRsJson -join "`n") | ConvertFrom-Json
567+
# Filter to forward flow PRs (not backflow) targeting this VMR branch
568+
$pendingForwardPRs = $allForward | Where-Object {
569+
$_.title -match "Source code updates from (dotnet/\S+)" -and
570+
$Matches[1] -ne "dotnet/dotnet"
571+
}
572+
}
573+
catch {
574+
Write-Warning "Failed to parse forward flow PR search results. Skipping forward flow analysis."
570575
}
571576
}
572577

0 commit comments

Comments
 (0)