From 29a0bc23c476c85514d3f2a2049b2473a9cdf9a1 Mon Sep 17 00:00:00 2001 From: "trop[bot]" Date: Tue, 12 Feb 2019 10:17:40 -0600 Subject: [PATCH] fix: release-notes plays more nicely with clerk (#16901) Explicitly look not just for Clerk's "notes persisted" message but also its "no release notes" message. --- script/release-notes/notes.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/script/release-notes/notes.js b/script/release-notes/notes.js index 8b00f51eca67d..85394269c0d57 100644 --- a/script/release-notes/notes.js +++ b/script/release-notes/notes.js @@ -69,6 +69,7 @@ const getNoteFromClerk = async (number, owner, repo) => { if (!comments || !comments.data) return const CLERK_LOGIN = 'release-clerk[bot]' + const CLERK_NO_NOTES = '**No Release Notes**' const PERSIST_LEAD = '**Release Notes Persisted**\n\n' const QUOTE_LEAD = '> ' @@ -76,18 +77,19 @@ const getNoteFromClerk = async (number, owner, repo) => { if (comment.user.login !== CLERK_LOGIN) { continue } - if (!comment.body.startsWith(PERSIST_LEAD)) { - continue + if (comment.body === CLERK_NO_NOTES) { + return NO_NOTES + } + if (comment.body.startsWith(PERSIST_LEAD)) { + return comment.body + .slice(PERSIST_LEAD.length).trim() // remove PERSIST_LEAD + .split('\r?\n') // break into lines + .map(line => line.trim()) + .filter(line => line.startsWith(QUOTE_LEAD)) // notes are quoted + .map(line => line.slice(QUOTE_LEAD.length)) // unquote the lines + .join(' ') // join the note lines + .trim() } - const note = comment.body - .slice(PERSIST_LEAD.length).trim() // remove PERSIST_LEAD - .split('\r?\n') // break into lines - .map(line => line.trim()) - .filter(line => line.startsWith(QUOTE_LEAD)) // notes are quoted - .map(line => line.slice(QUOTE_LEAD.length)) // unquote the lines - .join(' ') // join the note lines - .trim() - return note } }