Skip to content

Commit

Permalink
fix: release-notes plays more nicely with clerk (#16901)
Browse files Browse the repository at this point in the history
Explicitly look not just for Clerk's "notes persisted"
message but also its "no release notes" message.
  • Loading branch information
trop[bot] authored and ckerr committed Feb 12, 2019
1 parent f7508f1 commit 29a0bc2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions script/release-notes/notes.js
Expand Up @@ -69,25 +69,27 @@ 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 = '> '

for (const comment of comments.data.reverse()) {
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
}
}

Expand Down

0 comments on commit 29a0bc2

Please sign in to comment.