From 858e4fe86e45d1c877da691f5c8191582b88e2ab Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 20 Jul 2026 14:15:49 +0200 Subject: [PATCH] feat: add `sequence` format Hybrid format that can be pasted directly in the sequence editor of a `git rebase --interactive` session, without retaining info such as commit title, author, semverness, PR URL. --- commit-to-output.js | 9 +++++++-- process-commits.js | 2 ++ test.js | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/commit-to-output.js b/commit-to-output.js index 31bbfdb..d8d05b9 100644 --- a/commit-to-output.js +++ b/commit-to-output.js @@ -33,6 +33,7 @@ export const formatType = { SHA: 'sha', PLAINTEXT: 'plaintext', MARKDOWN: 'markdown', + SEQUENCE: 'sequence', SIMPLE: 'simple', MESSAGEONLY: 'messageonly' } @@ -60,7 +61,6 @@ function toStringPlaintext (data) { function toStringSimple (data) { let s = '' - s += `* [${data.sha.substr(0, 10)}] - ` s += (data.semver || []).length ? `(${data.semver.join(', ').toUpperCase()}) ` : '' s += data.revert ? 'Revert "' : '' s += data.group ? `${data.group}: ` : '' @@ -68,8 +68,11 @@ function toStringSimple (data) { s += data.revert ? '" ' : ' ' s += data.author ? `(${data.author}) ` : '' s += data.pr ? data.prUrl : '' - s = s.trim() + return s.trim() +} +function toStringSimpleWithListMarker (data) { + const s = `* [${data.sha.substr(0, 10)}] - ${toStringSimple(data)}` return (data.semver && data.semver.length) ? chalk.green.bold(s) : (data.group === 'doc' @@ -119,6 +122,8 @@ export function commitToOutput (commit, format, ghId, commitUrl) { data.cveId = commit.cveId if (format === formatType.SIMPLE) { + return toStringSimpleWithListMarker(data) + } else if (format === formatType.SEQUENCE) { return toStringSimple(data) } else if (format === formatType.PLAINTEXT) { return toStringPlaintext(data) diff --git a/process-commits.js b/process-commits.js index f3fa685..c3233b0 100644 --- a/process-commits.js +++ b/process-commits.js @@ -50,6 +50,8 @@ export async function processCommits (argv, ghId, list) { if (format === formatType.SHA) { list = list.map((commit) => `${commit.sha.substr(0, 10)}`) + } else if (format === formatType.SEQUENCE) { + list = list.map((commit) => `pick ${commit.sha} # ${commitToOutput(commit, format, ghId, commitUrl)}`) } else if ( format === formatType.PLAINTEXT || format === formatType.MESSAGEONLY diff --git a/test.js b/test.js index 2e2791c..ee5ad64 100644 --- a/test.js +++ b/test.js @@ -44,6 +44,18 @@ test('test simple', (t) => { `) t.end() }) +test('test sequence', (t) => { + t.equal(exec('--start-ref=v2.2.7 --end-ref=9c700d29 --group --filter-release --format=sequence'), + `pick cc442b65343cd1bb7cb4ecc3c6e729b4e4625f97 # (SEMVER-MINOR) minor nit (Rod Vagg) https://github.com/nodejs/node/pull/23715 +pick 4f2b7f8136358bc3ecd720e33457fdeff9581733 # deps: use strip-ansi instead of chalk.stripColor (Rod Vagg) +pick 6898501e18f231db40a84b511d2a6a4b8f5f17f3 # deps: update deps, introduce test & lint deps (Rod Vagg) +pick 9c700d29104b5a22fcf79ba21f5f009d7f1cdfc5 # feature: refactor and improve --commit-url (Rod Vagg) +pick 50945246557b4a25133435b106d0e5dd5d88a9be # feature: make the commit url configurable via an additional argument (Jim Nielsen) https://github.com/nodejs/changelog-maker/pull/55 +pick 42f248cf8904224a585e9f3834cc1283713c56cf # src: use \`standard\` for linting (Rod Vagg) +pick 64a8fdef3c35627ca50c48e9acb80c57a3f6d2a2 # test: basic test infrastructure (Rod Vagg) +`) + t.end() +}) test('test plaintext', (t) => { t.equal(exec('--start-ref=9c700d2 --end-ref=dd937e9 --group --filter-release --plaintext'),