Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-01-07 02:18:47 +0300
committerGitHub <noreply@github.com>2022-01-07 02:18:47 +0300
commit3b936544534fb342ceaa34a4cd26b650341cbe87 (patch)
treebd55dac54edbfb2e073765d23ed960fb26677640 /scripts
parentc942f3ab1b4a88e9e23e996043cc8a238da17a3d (diff)
fix(scripts): more complete commit message formatting (#4216)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/changelog.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/scripts/changelog.js b/scripts/changelog.js
index 9e12aa249..d385468f7 100644
--- a/scripts/changelog.js
+++ b/scripts/changelog.js
@@ -22,10 +22,15 @@ function printCommit (c) {
console.log(`* [\`${c.hash}\`](${c.url})`)
for (const pr of c.prs) {
console.log(` [#${pr.number}](${pr.url})`)
+ // remove the (#111) relating to this pull request from the commit message,
+ // since we manually add the link outside of the commit message
+ const msgRe = new RegExp(`\\s*\\(#${pr.number}\\)`, 'g')
+ c.message = c.message.replace(msgRe, '')
}
- console.log(` ${c.message}`)
- // no credit for deps commits
- if (!c.message.startsWith('deps')) {
+ // no need to indent this output, it's already got 2 spaces
+ console.log(c.message)
+ // no credit for deps commits, leading spaces are important here
+ if (!c.message.startsWith(' deps')) {
for (const user of c.credit) {
console.log(` ([${user.name}](${user.url}))`)
}
@@ -36,7 +41,7 @@ const main = async () => {
const query = `
fragment commitCredit on GitObject {
... on Commit {
- messageHeadline
+ message
url
authors (first:10) {
nodes {
@@ -74,7 +79,9 @@ const main = async () => {
const commit = {
hash: hash.slice(1), // remove leading _
url: data.url,
- message: data.messageHeadline.replace(/\(#\d+\)$/, ''),
+ message: data.message.replace(/(\r?\n)+/gm, '\n') // swap multiple new lines with one
+ .replace(/^/gm, ' ') // add two spaces to the start of each line
+ .replace(/([^\s]+@\d+\.\d+\.\d+.*)/g, '`$1`'), // wrap package@version in backticks
prs: data.associatedPullRequests.nodes.filter((pull) => pull.merged),
credit: data.authors.nodes.map((author) => {
if (author.user && author.user.login) {