fix: release-notes plays more nicely with clerk (#16887)

Explicitly look not just for Clerk's "notes persisted"
message but also its "no release notes" message.
This commit is contained in:
Charles Kerr 2019-02-12 08:21:20 -06:00 committed by John Kleinschmidt
parent 83894dc5db
commit cfbdc40814

View file

@ -56,6 +56,7 @@ const getNoteFromClerk = async (number, owner, repo) => {
if (!comments || !comments.data) return if (!comments || !comments.data) return
const CLERK_LOGIN = 'release-clerk[bot]' const CLERK_LOGIN = 'release-clerk[bot]'
const CLERK_NO_NOTES = '**No Release Notes**'
const PERSIST_LEAD = '**Release Notes Persisted**\n\n' const PERSIST_LEAD = '**Release Notes Persisted**\n\n'
const QUOTE_LEAD = '> ' const QUOTE_LEAD = '> '
@ -63,10 +64,11 @@ const getNoteFromClerk = async (number, owner, repo) => {
if (comment.user.login !== CLERK_LOGIN) { if (comment.user.login !== CLERK_LOGIN) {
continue continue
} }
if (!comment.body.startsWith(PERSIST_LEAD)) { if (comment.body === CLERK_NO_NOTES) {
continue return NO_NOTES
} }
const note = comment.body if (comment.body.startsWith(PERSIST_LEAD)) {
return comment.body
.slice(PERSIST_LEAD.length).trim() // remove PERSIST_LEAD .slice(PERSIST_LEAD.length).trim() // remove PERSIST_LEAD
.split('\r?\n') // break into lines .split('\r?\n') // break into lines
.map(line => line.trim()) .map(line => line.trim())
@ -74,7 +76,7 @@ const getNoteFromClerk = async (number, owner, repo) => {
.map(line => line.slice(QUOTE_LEAD.length)) // unquote the lines .map(line => line.slice(QUOTE_LEAD.length)) // unquote the lines
.join(' ') // join the note lines .join(' ') // join the note lines
.trim() .trim()
return note }
} }
} }