From ad07750d63cb51e357e423f77c95c37a685199f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 12:35:29 +0000 Subject: [PATCH 1/2] chore(deps): bump changelog-maker from 4.4.52 to 5.0.5 Bumps [changelog-maker](https://github.com/nodejs/changelog-maker) from 4.4.52 to 5.0.5. - [Release notes](https://github.com/nodejs/changelog-maker/releases) - [Changelog](https://github.com/nodejs/changelog-maker/blob/main/CHANGELOG.md) - [Commits](https://github.com/nodejs/changelog-maker/compare/v4.4.52...v5.0.5) --- updated-dependencies: - dependency-name: changelog-maker dependency-version: 5.0.5 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fc68d0..2af2080 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "author": "Rod (http://r.va.gg/)", "license": "MIT", "dependencies": { - "changelog-maker": "^4.0.0", + "changelog-maker": "^5.0.5", "commit-stream": "^2.0.1", "gitexec": "^2.0.1", "minimist": "^1.2.8", From e77e72b3af0cb3cf058b300be6968a98f6593956 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 5 Oct 2026 19:40:42 +1100 Subject: [PATCH 2/2] fix!: strict CLI parsing, drop legacy format shorthands Adopt changelog-maker v5 behaviour: util.parseArgs replaces minimist, unknown options are an error. BREAKING CHANGE: --sha, --plaintext, --markdown and --simple are removed; use --format=. --- README.md | 16 ++++++++------ branch-diff.js | 60 ++++++++++++++++++++++++-------------------------- package.json | 1 - 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index de5fe8d..b8719eb 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ ## Usage -**`$ branch-diff [--sha] [--plaintext] [--markdown] [--group] [--reverse] [--patch-only] base-branch comparison-branch`** +**`$ branch-diff [--format=] [--group] [--reverse] [--patch-only] base-branch comparison-branch`** A commit is considered to be in the comparison-branch but not in the base-branch if: * the commit sha is identical, or * the commit summary is identical _and_ the commit description is identical _and_ a `PR-URL` exists in the metadata and is identical (in the description but split out by commit-stream) -The output is the same as [changelog-maker](https://github.com/rvagg/changelog-maker/) and you can use `--simple` to simplify it for console output instead of Markdown. +The output is the same as [changelog-maker](https://github.com/nodejs/changelog-maker/). The default `simple` format suits console output; use `--format=markdown` for Markdown. The commit list is very close to running: @@ -24,25 +24,27 @@ But the comparison isn't quite as strict, generally leading to a shorter list of ### Options -* `--version`: Only prints branch-diff's package.json version. +* `--version` or `-v`: Only prints branch-diff's package.json version. * `--group` or `-g`: Group commits by prefix, this uses the part of the commit summary that is usually used in Node.js core to indicate subsystem for example. Groups are made up of numbers, letters, `,` and `-`, followed by a `:`. * `--exclude-label`: Exclude any commits from the list that come from a GitHub pull request with the given label. Multiple `--exclude-label` options may be provided, they will also be split by `,`. e.g. `--exclude-label=semver-major,meta`. * `--require-label`: Only include commits in the list that come from a GitHub pull request with the given label. Multiple `--require-label` options may be provided, they will also be split by `,`. e.g. `--require-label=test,doc`. * `--patch-only`: An alias for `--exclude-label=semver-major,semver-minor`. -* `--format`: Dictates what formatting the output will have. Possible options are: `simple`, `markdown`, `plaintext`, and `sha`. The default is to print a `simple` output suitable for stdout. +* `--format`: Dictates what formatting the output will have. Possible options are: `simple`, `markdown`, `plaintext`, `messageonly` and `sha`. The default is to print a `simple` output suitable for stdout. An unknown format is an error. - `simple`: Don't print full markdown output, good for console printing without the additional fluff. - `sha`: Print only the 10-character truncated commit hashes. Good for piping though additional tooling, such as `xargs git cherry-pick` for applying commits. - `plaintext`: A very simple form, without commit details, implies `--group`. - `markdown`: A Markdown formatted from, with links and proper escaping. -* `--sha`: Same as `--format=sha`. -* `--plaintext`: Same as `--format=plaintext`. -* `--markdown`: Same as `--format=markdown`. + - `messageonly`: Only the commit message, implies `--group`. * `--filter-release`: Exclude Node-style release commits from the list. e.g. `Working on v1.0.0` or `2015-10-21 Version 2.0.0`. * `--reverse`: Reverse the results, this is especially useful when piping output to `xargs`. * `--commit-url`:A URL template which will be used to generate commit URLs for a repository not hosted in GitHub. `{ref}` is the placeholder that will be replaced with the commit, i.e. `--commit-url=https://gitlab.com/myUser/myRepo/commit/{ref}`. `{ghUser}` and `{ghRepo}` are available if they can be derived from package.json (Gitlab and Bitbucket URLs should be understood in package.json). +* `--find-matching-prs`: Use the GitHub API to find the pull requests that match commits that don't have `PR-URL` metadata in their message text. +* `--quiet` or `-q`: Do not print to stdout. * `--user`: Override the auto-detected GitHub user/org derived from package.json * `--repo`: Override the auto-detected GitHub repository name derived from package.json +Unknown options are an error. The `--sha`, `--plaintext`, `--markdown` and `--simple` shorthands were removed in v4; use `--format=`. + ## License **branch-diff** is Copyright (c) 2015 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. diff --git a/branch-diff.js b/branch-diff.js index 27179b4..6c206f5 100755 --- a/branch-diff.js +++ b/branch-diff.js @@ -5,11 +5,10 @@ import { createRequire } from 'module' import path from 'path' import process from 'process' import { pipeline } from 'stream/promises' -import { promisify } from 'util' +import { parseArgs, promisify } from 'util' import commitStream from 'commit-stream' import split2 from 'split2' import pkgtoId from 'pkg-to-id' -import minimist from 'minimist' import { isReleaseCommit } from 'changelog-maker/groups' import { processCommits } from 'changelog-maker/process-commits' import { collectCommitLabels } from 'changelog-maker/collect-commit-labels' @@ -122,38 +121,37 @@ async function collect (repoPath, branch, startCommit, endRef) { } async function main () { - const minimistConfig = { - boolean: ['version', 'group', 'patch-only', 'simple', 'filter-release', 'reverse'] - } - const argv = minimist(process.argv.slice(2), minimistConfig) - const branch1 = argv._[0] - const branch2 = argv._[1] - const group = argv.group || argv.g - const endRef = argv['end-ref'] - let excludeLabels = [] - let requireLabels = [] - - if (argv.version || argv.v) { + const { values: argv, positionals } = parseArgs({ + allowPositionals: true, + options: { + 'commit-url': { type: 'string' }, + 'end-ref': { type: 'string' }, + 'exclude-label': { type: 'string', multiple: true }, + 'filter-release': { type: 'boolean' }, + 'find-matching-prs': { type: 'boolean' }, + format: { type: 'string' }, + group: { type: 'boolean', short: 'g' }, + 'patch-only': { type: 'boolean' }, + quiet: { type: 'boolean', short: 'q' }, + repo: { type: 'string' }, + 'require-label': { type: 'string', multiple: true }, + reverse: { type: 'boolean' }, + user: { type: 'string' }, + version: { type: 'boolean', short: 'v' } + } + }) + const [branch1, branch2] = positionals + const splitLabels = (labels = []) => labels.flatMap((l) => l.split(',')) + + if (argv.version) { return console.log(`v ${require('./package.json').version}`) } + const excludeLabels = splitLabels(argv['exclude-label']) if (argv['patch-only']) { - excludeLabels = ['semver-minor', 'semver-major'] - } - - if (argv['exclude-label']) { - if (!Array.isArray(argv['exclude-label'])) { - argv['exclude-label'] = argv['exclude-label'].split(',') - } - excludeLabels = excludeLabels.concat(argv['exclude-label']) - } - - if (argv['require-label']) { - if (!Array.isArray(argv['require-label'])) { - argv['require-label'] = argv['require-label'].split(',') - } - requireLabels = requireLabels.concat(argv['require-label']) + excludeLabels.unshift('semver-minor', 'semver-major') } + const requireLabels = splitLabels(argv['require-label']) if (argv.user) { ghId.user = argv.user @@ -164,10 +162,10 @@ async function main () { } const options = { - group, + group: argv.group, excludeLabels, requireLabels, - endRef + endRef: argv['end-ref'] } let list = await branchDiff(branch1, branch2, options) diff --git a/package.json b/package.json index 2af2080..5ee1d90 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "changelog-maker": "^5.0.5", "commit-stream": "^2.0.1", "gitexec": "^2.0.1", - "minimist": "^1.2.8", "pkg-to-id": "^0.0.3", "split2": "^4.2.0" },