Skip to content

Commit

Permalink
Capture PR body when scanning (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
apexskier authored Oct 9, 2020
1 parent 58609b0 commit 80cba13
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
13 changes: 9 additions & 4 deletions dst/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object {
}
edges {
node {
title
bodyHTML
number
timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) {
pageInfo {
Expand Down Expand Up @@ -65,7 +65,7 @@ Object {
}
edges {
node {
title
bodyHTML
number
timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) {
pageInfo {
Expand Down Expand Up @@ -127,6 +127,18 @@ Object {
"issue_number": 123,
},
],
Array [
Object {
"body": "Included in release [current_tag_name](http://current_release)",
"issue_number": 4,
},
],
Array [
Object {
"body": "Included in release [current_tag_name](http://current_release)",
"issue_number": 5,
},
],
Array [
Object {
"body": "Included in release [current_tag_name](http://current_release)",
Expand All @@ -147,6 +159,14 @@ Object {
"type": "return",
"value": Promise {},
},
Object {
"type": "return",
"value": Promise {},
},
Object {
"type": "return",
"value": Promise {},
},
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ test("main test", async () => {
edges: [
{
node: {
bodyHTML:
'<span class="issue-keyword tooltipped tooltipped-se" aria-label="This commit closes issue #4.">Closes</span> <span class="issue-keyword tooltipped tooltipped-se" aria-label="This commit closes issue #5.">Closes</span>',
timelineItems: {
pageInfo: { hasNextPage: false },
nodes: [
Expand Down
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const closesMatcher = /aria-label="This commit closes issue #(\d+)\."/g;
}
edges {
node {
title
bodyHTML
number
timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) {
pageInfo {
Expand Down Expand Up @@ -99,7 +99,7 @@ const closesMatcher = /aria-label="This commit closes issue #(\d+)\."/g;
pageInfo: { hasNextPage: boolean };
edges: Array<{
node: {
title: string;
bodyHTML: string;
number: number;
timelineItems: {
pageInfo: { hasNextPage: boolean };
Expand All @@ -123,10 +123,13 @@ const closesMatcher = /aria-label="This commit closes issue #(\d+)\."/g;

core.info(JSON.stringify(response.resource, null, 2));

const html =
response.resource.messageHeadlineHTML +
" " +
response.resource.messageBodyHTML;
const html = [
response.resource.messageHeadlineHTML,
response.resource.messageBodyHTML,
...response.resource.associatedPullRequests.edges.map(
(pr) => pr.node.bodyHTML
),
].join(" ");
for (const match of html.matchAll(closesMatcher)) {
const [, num] = match;
linkedIssuesPrs.add(num);
Expand Down

0 comments on commit 80cba13

Please sign in to comment.