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.
This commit is contained in:
Jérémie Astori 2019-01-30 00:34:39 -05:00
parent 85d87a3b37
commit 682207ffe6
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8

View File

@ -256,6 +256,7 @@ class RepositoryFetcher {
endCursor endCursor
} }
commits: nodes { commits: nodes {
__typename
oid oid
abbreviatedOid abbreviatedOid
messageHeadline messageHeadline
@ -378,6 +379,7 @@ class RepositoryFetcher {
repository(owner: "thelounge", name: $repositoryName) { repository(owner: "thelounge", name: $repositoryName) {
${numbers.map((number) => ` ${numbers.map((number) => `
PR${number}: pullRequest(number: ${number}) { PR${number}: pullRequest(number: ${number}) {
__typename
title title
url url
author { author {
@ -457,7 +459,7 @@ function printAuthorLink({login, url}) {
// Builds a Markdown link for a given pull request or commit object // Builds a Markdown link for a given pull request or commit object
function printEntryLink(entry) { function printEntryLink(entry) {
const label = entry.title const label = entry.__typename === "PullRequest"
? `#${entry.number}` ? `#${entry.number}`
: `\`${entry.abbreviatedOid}\``; : `\`${entry.abbreviatedOid}\``;
@ -466,7 +468,7 @@ function printEntryLink(entry) {
// Builds a Markdown entry list item depending on its type // Builds a Markdown entry list item depending on its type
function printLine(entry) { function printLine(entry) {
if (entry.title) { if (entry.__typename === "PullRequest") {
return printPullRequest(entry); return printPullRequest(entry);
} }
@ -550,7 +552,7 @@ function hasAnnotatedComment(comments, expected) {
function isSkipped(entry) { function isSkipped(entry) {
return ( return (
(entry.messageHeadline && ( (entry.__typename === "Commit" && (
// Version bump commits created by `yarn version` // Version bump commits created by `yarn version`
isValidVersion(entry.messageHeadline) || isValidVersion(entry.messageHeadline) ||
// Commit message suggested by this script // Commit message suggested by this script