From 682207ffe65381b1c5d7ab86dd3801ef7684f32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Wed, 30 Jan 2019 00:34:39 -0500 Subject: [PATCH] Use a __typename on commits and pull requests to discriminate on types This was done by checking if the entry had a title or a messageHeadline, which is rather brittle. --- scripts/changelog.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/changelog.js b/scripts/changelog.js index a43d4d35..0bfba744 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -256,6 +256,7 @@ class RepositoryFetcher { endCursor } commits: nodes { + __typename oid abbreviatedOid messageHeadline @@ -378,6 +379,7 @@ class RepositoryFetcher { repository(owner: "thelounge", name: $repositoryName) { ${numbers.map((number) => ` PR${number}: pullRequest(number: ${number}) { + __typename title url author { @@ -457,7 +459,7 @@ function printAuthorLink({login, url}) { // Builds a Markdown link for a given pull request or commit object function printEntryLink(entry) { - const label = entry.title + const label = entry.__typename === "PullRequest" ? `#${entry.number}` : `\`${entry.abbreviatedOid}\``; @@ -466,7 +468,7 @@ function printEntryLink(entry) { // Builds a Markdown entry list item depending on its type function printLine(entry) { - if (entry.title) { + if (entry.__typename === "PullRequest") { return printPullRequest(entry); } @@ -550,7 +552,7 @@ function hasAnnotatedComment(comments, expected) { function isSkipped(entry) { return ( - (entry.messageHeadline && ( + (entry.__typename === "Commit" && ( // Version bump commits created by `yarn version` isValidVersion(entry.messageHeadline) || // Commit message suggested by this script