Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/app/api/issues/reconcile/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,29 @@
totalMergedPrsFound += mergedPrsMap.size;
totalOpenPrsChecked += openPrsMap.size;

// Extract issue numbers from merged PR bodies (if available via branch names)
// Extract issue numbers from merged PRs: scan body keywords first, then
// fall back to branch name patterns so we catch "Fixes #NNN", "Closes #NNN",
// "Resolves #NNN" references that workers write in PR bodies.
const mergedFixingIssues = new Map<number, typeof allPrs[number]>();
for (const [, pr] of mergedPrsMap) {
// Use branch name as proxy for issue reference
const branch = pr.head?.ref ?? "";
const match = branch.match(/issue[-_/]?(\d+)/i);
if (match) {
const issueNum = parseInt(match[1], 10);
if (!isNaN(issueNum)) {
mergedFixingIssues.set(issueNum, pr);
// 1. Check PR body for keyword references (Fixes #, Closes #, Resolves #)
const bodyNumbers = extractFixingIssueNumbers(pr.body ?? pr.title ?? null);

Check failure on line 95 in src/app/api/issues/reconcile/route.ts

View workflow job for this annotation

GitHub Actions / Validate

Property 'body' does not exist on type 'GithubPR'.
for (const num of bodyNumbers) {
if (!mergedFixingIssues.has(num)) {
mergedFixingIssues.set(num, pr);
}
}
// 2. Fallback: check branch name pattern
if (!mergedFixingIssues.has(pr.number)) {
const branch = pr.head?.ref ?? "";
const match = branch.match(/issue[-_/]?(\d+)/i);
if (match) {
const issueNum = parseInt(match[1], 10);
if (!isNaN(issueNum)) {
if (!mergedFixingIssues.has(issueNum)) {
mergedFixingIssues.set(issueNum, pr);
}
}
}
}
}
Expand Down
Loading