diff --git a/scripts/changelog.js b/scripts/changelog.js index 0e84fc24fba3d..f36ad56c9c5bf 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -32,12 +32,12 @@ function shortname (url) { function printCommit (c) { console.log(`* [\`${c.shortid}\`](https://github.com/npm/cli/commit/${c.fullid})`) - if (c.fixes) { - let label = shortname(c.fixes) - if (label) { - console.log(` [${label}](${c.fixes})`) - } else { - console.log(` [npm.community#${c.fixes}](https://npm.community/t/${c.fixes})`) + if (c.fixes.length) { + for (const fix of c.fixes) { + let label = shortname(fix) + if (label) { + console.log(` [${label}](${fix})`) + } } } else if (c.prurl) { let label = shortname(c.prurl) @@ -51,20 +51,23 @@ function printCommit (c) { .replace(/^\s+/mg, '') .replace(/^[-a-z]+: /, '') .replace(/^/mg, ' ') + .replace(/^ Reviewed-by: @.*/mg, '') .replace(/\n$/, '') // backtickify package@version - .replace(/^(\s*@?[^@\s]+@\d+[.]\d+[.]\d+)(\s*\S)/g, '$1:$2') + .replace(/^(\s*@?[^@\s]+@\d+[.]\d+[.]\d+)\b(\s*\S)/g, '$1:$2') .replace(/((?:\b|@)[^@\s]+@\d+[.]\d+[.]\d+)\b/g, '`$1`') // linkify commitids .replace(/\b([a-f0-9]{7,8})\b/g, '[`$1`](https://github.com/npm/cli/commit/$1)') - .replace(/\b#(\d+)\b/g, '[#$1](https://npm.community/t/$1)') console.log(msg) - if (c.credit) { - c.credit.forEach(function (credit) { - console.log(` ([@${credit}](https://github.com/${credit}))`) - }) - } else { - console.log(` ([@${c.author}](https://github.com/${c.author}))`) + // don't assign credit for dep updates + if (!/^ `[^`]+@\d+\.\d+\.\d+[^`]*`:?$/m.test(msg)) { + if (c.credit) { + c.credit.forEach(function (credit) { + console.log(` ([@${credit}](https://github.com/${credit}))`) + }) + } else { + console.log(` ([@${c.author}](https://github.com/${c.author}))`) + } } } @@ -84,7 +87,7 @@ function main () { message: m[4], author: m[5], prurl: null, - fixes: null, + fixes: [], credit: null } } else if (m = line.match(/^PR-URL: (.*)/)) { @@ -92,8 +95,12 @@ function main () { } else if (m = line.match(/^Credit: @(.*)/)) { if (!commit.credit) commit.credit = [] commit.credit.push(m[1]) - } else if (m = line.match(/^Fixes: #?(.*)/)) { - commit.fixes = m[1] + } else if (m = line.match(/^(?:Fix(?:es)|Closes?): #?([0-9]+)/)) { + commit.fixes.push(`https://github.com/npm/cli/issues/${m[1]}`) + } else if (m = line.match(/^(?:Fix(?:es)|Closes?): ([^#]+)#([0-9]*)/)) { + commit.fixes.push(`https://github.com/${m[1]}/issues/${m[2]}`) + } else if (m = line.match(/^(?:Fix(?:es)|Closes?): (https?:\/\/.*)/)) { + commit.fixes.push(m[1]) } else if (m = line.match(/^Reviewed-By: @(.*)/)) { commit.reviewed = m[1] } else if (/\S/.test(line)) {