Skip to content
Merged
Changes from all commits
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
17 changes: 11 additions & 6 deletions scripts/unassign-inactive-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,32 @@ const checkLinkedPRs = async (issue, github, owner, repo) => {
console.error(`Error fetching timeline for issue #${issue.number}:`, timelineError.message);
}

// Method 2: Search for PRs that mention this issue
// Method 2: Search for PRs that mention this issue using the updated endpoint
try {
const searchQuery = `repo:${owner}/${repo} type:pr is:open ${issue.number} in:body,title`;
const searchResult = await github.rest.search.issuesAndPullRequests({

const searchResult = await github.request('GET /search/issues', {
q: searchQuery,
advanced_search: true, // Enable advanced search
headers: {
'Accept': 'application/vnd.github+json',
}
});

// Local regex for "closes/fixes/resolves #123"
const closingRegex = new RegExp(
`(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\\s*:?\\s*#${issue.number}`,
"i"
);

for (const prItem of searchResult.data.items || []) {
if (prItem.pull_request && prItem.number) {
const prDetails = await github.rest.pulls.get({
owner,
repo,
pull_number: prItem.number,
});

if (prDetails.data.state === "open") {
const prBody = prDetails.data.body || "";
const prTitle = prDetails.data.title || "";
Expand All @@ -174,7 +179,7 @@ const checkLinkedPRs = async (issue, github, owner, repo) => {
}
} catch (searchError) {
console.log('Search API error:', searchError.message);
}
}
// Return the Set of linked PR numbers (always return a Set)
return linkedPRs;
} catch (error) {
Expand Down