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:
authorLuke Karrys <luke@lukekarrys.com>2022-04-15 01:38:46 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-04-20 02:27:03 +0300
commit8cf4fc41fe3624746f2c8858c47ab0802903ee07 (patch)
treef39e2baa91c9f7aa3214d89daf5d52c3cd095585 /scripts
parent21375c6c356e9beddbc96720b1d03ea2db05be0e (diff)
chore(changelog): dont show commit body by default & add extra pr check
We don't usually include the commit body in the release notes, so this removes it from the output by default. It's now behind the `--format=long` flag, and the command can be rerun with that in case we need the full commit body sometimes. Also do an extra check for PR references in titles, since squashed PRs don't always include the `associatedPullRequests`.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/changelog.js50
1 files changed, 40 insertions, 10 deletions
diff --git a/scripts/changelog.js b/scripts/changelog.js
index f91e28d5a..1d8db9272 100644
--- a/scripts/changelog.js
+++ b/scripts/changelog.js
@@ -97,7 +97,7 @@ const assertArgs = (args) => {
return process.exit(0)
}
- if (args.unsafe) {
+ if (args.force) {
// just to make manual testing easier
return args
}
@@ -109,7 +109,7 @@ const assertArgs = (args) => {
const current = exec(`git rev-parse --abbrev-ref HEAD`)
if (current !== args.branch) {
- throw new Error(`Must be on branch "${args.branch}"`)
+ throw new Error(`Must be on branch "${args.branch}", rerun with --force to override`)
}
const localLog = exec(`git log ${remoteBranch}..HEAD`).length > 0
@@ -130,10 +130,11 @@ const parseArgs = (argv) => {
branch: 'latest',
remote: 'origin',
type: 'md', // or 'gh'
+ format: 'short', // or 'long'
write: false,
read: false,
help: false,
- unsafe: false,
+ force: false,
}
for (const arg of argv) {
@@ -270,6 +271,29 @@ const generateRelease = async (args) => {
let [title, ...body] = message.split('\n')
const prs = commit.associatedPullRequests.nodes.filter((pull) => pull.merged)
+
+ // external squashed PRs dont get the associated pr node set
+ // so we try to grab it from the end of the commit title
+ // since thats where it goes by default
+ const [, titleNumber] = title.match(/\s+\(#(\d+)\)$/) || []
+ console.log(prs, titleNumber)
+ if (titleNumber && !prs.find((pr) => pr.number === +titleNumber)) {
+ console.log('no title')
+ try {
+ // it could also reference an issue so we do one extra check
+ // to make sure it is really a pr that has been merged
+ const realPr = JSON.parse(exec(`gh pr view ${titleNumber} --json url,number,state`, {
+ stdio: 'pipe',
+ }))
+ if (realPr.state === 'MERGED') {
+ prs.push(realPr)
+ }
+ } catch {
+ // maybe an issue or something else went wrong
+ // not super important so keep going
+ }
+ }
+
for (const pr of prs) {
title = title.replace(new RegExp(`\\s*\\(#${pr.number}\\)`, 'g'), '')
}
@@ -343,7 +367,8 @@ const generateRelease = async (args) => {
}
output.group(groupCommit)
- if (commit.body && commit.body.length) {
+ // only optionally add full commit bodies to changelog
+ if (commit.body && commit.body.length && args.format === 'long') {
output.log(commit.body)
}
output.groupEnd()
@@ -378,13 +403,18 @@ const main = async (argv) => {
// otherwise fetch the requested release from github
const { release, version, date } = await generateRelease(args)
- try {
- exec(`node scripts/release-manager.js --update --version=${version.slice(1)} --date=${date}`)
- } catch {
- // optionally update release manager issue
- }
-
if (args.write) {
+ // only try and run release manager issue update on write since that signals
+ // the first time we know the version of the release
+ try {
+ exec(
+ `node scripts/release-manager.js --update --version=${version.slice(1)} --date=${date}`, {
+ stdio: 'pipe',
+ })
+ } catch (e) {
+ console.error(`Updating release manager issue failed: ${e.stderr}`)
+ }
+
const { release: existing, changelog } = findRelease(args, version)
fs.writeFileSync(
args.file,