Skip to content

Commit 7647246

Browse files
committed
Build/Test Tools: Remove in:body from pull request search query.
When searching for pull requests using the GraphQL API, `in:body` is not being respected in search queries. Because it’s common for Trac tickets to be referenced in the discussions happening in comments and reviews, some pull requests are being closed out incorrectly. This removes `in:body` from the search query introduced in [59661] and instead checks the `bodyText` for references to the fixed tickets. The `state` field is also being removed because it is unused. Props dd32, peterwilsoncc, johnbillion, joedolson, westonruter, dmsnell. Fixes #64175. git-svn-id: https://develop.svn.wordpress.org/trunk@61100 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e0eb90b commit 7647246

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/reusable-cleanup-pull-requests.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,36 @@ jobs:
5454
5555
for (const ticket of fixedList) {
5656
const tracTicketUrl = `https://core.trac.wordpress.org/ticket/${ticket}`;
57-
const corePrefix = `Core-${ticket}`;
57+
const corePrefix = `core-${ticket}`;
5858
5959
const query = `
6060
query($searchQuery: String!) {
6161
search(query: $searchQuery, type: ISSUE_ADVANCED, first: 20) {
6262
nodes {
6363
... on PullRequest {
6464
number
65-
state
65+
bodyText
6666
}
6767
}
6868
}
6969
}
7070
`;
7171
72-
const searchQuery = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:open in:body ( "${tracTicketUrl}" OR "${corePrefix}" )`;
72+
const searchQuery = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:open ( "${tracTicketUrl}" OR "${corePrefix}" )`;
7373
7474
const result = await github.graphql(query, {
7575
searchQuery,
7676
});
7777
78-
prNumbers.push(...result.search.nodes.map(pr => pr.number));
78+
// Since search queries will match anywhere for any activity on a pull request, the body specifically needs to be manually checked.
79+
const matchingPRs = result.search.nodes
80+
.filter(
81+
const bodyLower = pr.bodyText.toLowerCase();
82+
pr => pr.bodyText.includes(tracTicketUrl) || pr.bodyText.includes(corePrefix)
83+
)
84+
.map(pr => pr.number);
85+
86+
prNumbers.push(...matchingPRs);
7987
}
8088
8189
return prNumbers;

0 commit comments

Comments
 (0)