From 80cba137daee2d56d9d8a5ceeae43e0133f2a6dd Mon Sep 17 00:00:00 2001 From: Cameron Little Date: Fri, 9 Oct 2020 22:11:15 +0200 Subject: [PATCH] Capture PR body when scanning (#8) --- dst/index.js | 13 +++++++++---- src/__snapshots__/index.test.ts.snap | 24 ++++++++++++++++++++++-- src/index.test.ts | 2 ++ src/index.ts | 15 +++++++++------ 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/dst/index.js b/dst/index.js index d70e5614..5b8da194 100644 --- a/dst/index.js +++ b/dst/index.js @@ -62,6 +62,10 @@ var __read = (this && this.__read) || function (o, n) { } return ar; }; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); @@ -114,7 +118,7 @@ var closesMatcher = /aria-label="This commit closes issue #(\d+)\."/g; return __generator(this, function (_g) { switch (_g.label) { case 0: - query = "\n {\n resource(url: \"" + payload_1.repository.html_url + "/commit/" + commit.sha + "\") {\n ... on Commit {\n messageHeadlineHTML\n messageBodyHTML\n associatedPullRequests(first: 10) {\n pageInfo {\n hasNextPage\n }\n edges {\n node {\n title\n number\n timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) {\n pageInfo {\n hasNextPage\n }\n nodes {\n ... on ConnectedEvent {\n __typename\n isCrossRepository\n subject {\n ... on Issue {\n number\n }\n }\n }\n ... on DisconnectedEvent {\n __typename\n isCrossRepository\n subject {\n ... on Issue {\n number\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n "; + query = "\n {\n resource(url: \"" + payload_1.repository.html_url + "/commit/" + commit.sha + "\") {\n ... on Commit {\n messageHeadlineHTML\n messageBodyHTML\n associatedPullRequests(first: 10) {\n pageInfo {\n hasNextPage\n }\n edges {\n node {\n bodyHTML\n number\n timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) {\n pageInfo {\n hasNextPage\n }\n nodes {\n ... on ConnectedEvent {\n __typename\n isCrossRepository\n subject {\n ... on Issue {\n number\n }\n }\n }\n ... on DisconnectedEvent {\n __typename\n isCrossRepository\n subject {\n ... on Issue {\n number\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n "; return [4 /*yield*/, octokit_1.graphql(query)]; case 1: response = _g.sent(); @@ -122,9 +126,10 @@ var closesMatcher = /aria-label="This commit closes issue #(\d+)\."/g; return [2 /*return*/]; } core.info(JSON.stringify(response.resource, null, 2)); - html = response.resource.messageHeadlineHTML + - " " + - response.resource.messageBodyHTML; + html = __spread([ + response.resource.messageHeadlineHTML, + response.resource.messageBodyHTML + ], response.resource.associatedPullRequests.edges.map(function (pr) { return pr.node.bodyHTML; })).join(" "); try { for (_a = __values(html.matchAll(closesMatcher)), _b = _a.next(); !_b.done; _b = _a.next()) { match = _b.value; diff --git a/src/__snapshots__/index.test.ts.snap b/src/__snapshots__/index.test.ts.snap index 261f5b19..c556fdd2 100644 --- a/src/__snapshots__/index.test.ts.snap +++ b/src/__snapshots__/index.test.ts.snap @@ -17,7 +17,7 @@ Object { } edges { node { - title + bodyHTML number timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) { pageInfo { @@ -65,7 +65,7 @@ Object { } edges { node { - title + bodyHTML number timelineItems(itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT], first: 100) { pageInfo { @@ -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)", @@ -147,6 +159,14 @@ Object { "type": "return", "value": Promise {}, }, + Object { + "type": "return", + "value": Promise {}, + }, + Object { + "type": "return", + "value": Promise {}, + }, ], }, }, diff --git a/src/index.test.ts b/src/index.test.ts index c33d029e..8935c2b2 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -53,6 +53,8 @@ test("main test", async () => { edges: [ { node: { + bodyHTML: + 'Closes Closes', timelineItems: { pageInfo: { hasNextPage: false }, nodes: [ diff --git a/src/index.ts b/src/index.ts index 2e69081d..faacf9c9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { @@ -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 }; @@ -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);