From f552db74ef8b48b52f727c5673cbc1c1878f6383 Mon Sep 17 00:00:00 2001 From: zbynekstara Date: Thu, 20 Aug 2026 13:25:18 +0200 Subject: [PATCH 1/5] chore: custom changeset changelog format --- .changeset/changelog.cjs | 40 ++++++++++++++++++++++++++++++++++++++++ .changeset/config.json | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .changeset/changelog.cjs diff --git a/.changeset/changelog.cjs b/.changeset/changelog.cjs new file mode 100644 index 0000000000..bcd8f0e7fc --- /dev/null +++ b/.changeset/changelog.cjs @@ -0,0 +1,40 @@ +// Changelog line format: `- ()`. +// +// This replaces the default `@changesets/cli/changelog`, which renders the same +// information as a `: ` prefix instead. `changeset.commit` is the +// full SHA of the commit that added the changeset file, resolved by Changesets +// from local git history - no GitHub token or API request is involved. It is +// `undefined` when the changeset file has not been committed yet (a local +// `changeset version` run), in which case the suffix is omitted. +// +// `getDependencyReleaseLine` is a verbatim port of the default implementation, +// so "Updated dependencies" blocks are unchanged. +const SHA_LENGTH = 7; + +module.exports = { + getReleaseLine: async (changeset) => { + const [firstLine, ...continuationLines] = changeset.summary + .split('\n') + .map((line) => line.trimEnd()); + const sha = changeset.commit + ? ` (${changeset.commit.slice(0, SHA_LENGTH)})` + : ''; + let releaseLine = `- ${firstLine}${sha}`; + if (continuationLines.length > 0) { + releaseLine += `\n${continuationLines.map((line) => ` ${line}`).join('\n')}`; + } + return releaseLine; + }, + + getDependencyReleaseLine: async (changesets, dependenciesUpdated) => { + if (dependenciesUpdated.length === 0) return ''; + const changesetLinks = changesets.map( + (changeset) => + `- Updated dependencies${changeset.commit ? ` [${changeset.commit.slice(0, SHA_LENGTH)}]` : ''}` + ); + const updatedDependenciesList = dependenciesUpdated.map( + (dependency) => ` - ${dependency.name}@${dependency.newVersion}` + ); + return [...changesetLinks, ...updatedDependenciesList].join('\n'); + }, +}; diff --git a/.changeset/config.json b/.changeset/config.json index 6e40ab11bc..7eed5e1bae 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -2,7 +2,7 @@ "$schema": "https://unpkg.com/@changesets/config@4.0.0/schema.json", "baseBranch": "master", "access": "public", - "changelog": "@changesets/cli/changelog", + "changelog": "./changelog.cjs", "commit": false, "ignore": [], "fixed": [], From 86a3622c72419873ae5a3a3a16cb4f6ab072a919 Mon Sep 17 00:00:00 2001 From: zbynekstara Date: Fri, 21 Aug 2026 11:03:51 +0200 Subject: [PATCH 2/5] consolidate Updated dependencies lines in changelog --- .changeset/changelog.cjs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.changeset/changelog.cjs b/.changeset/changelog.cjs index bcd8f0e7fc..11db7afc13 100644 --- a/.changeset/changelog.cjs +++ b/.changeset/changelog.cjs @@ -28,13 +28,22 @@ module.exports = { getDependencyReleaseLine: async (changesets, dependenciesUpdated) => { if (dependenciesUpdated.length === 0) return ''; - const changesetLinks = changesets.map( - (changeset) => - `- Updated dependencies${changeset.commit ? ` [${changeset.commit.slice(0, SHA_LENGTH)}]` : ''}` - ); - const updatedDependenciesList = dependenciesUpdated.map( - (dependency) => ` - ${dependency.name}@${dependency.newVersion}` - ); - return [...changesetLinks, ...updatedDependenciesList].join('\n'); + // One line for all contributing commits, not one line per changeset. + // Changesets that are not committed yet contribute no SHA, and a single + // commit adding several changesets is only listed once. + const shas = [ + ...new Set( + changesets + .filter((changeset) => changeset.commit) + .map((changeset) => changeset.commit.slice(0, SHA_LENGTH)) + ), + ]; + const suffix = shas.length > 0 ? ` (${shas.join(', ')})` : ''; + return [ + `- Updated dependencies${suffix}`, + ...dependenciesUpdated.map( + (dependency) => ` - ${dependency.name}@${dependency.newVersion}` + ), + ].join('\n'); }, }; From 5a9297b580dd3135cadad80f9c39324a53dfdd12 Mon Sep 17 00:00:00 2001 From: zbynekstara Date: Fri, 21 Aug 2026 11:34:19 +0200 Subject: [PATCH 3/5] update --- .changeset/changelog.cjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.changeset/changelog.cjs b/.changeset/changelog.cjs index 11db7afc13..6af2f7c33d 100644 --- a/.changeset/changelog.cjs +++ b/.changeset/changelog.cjs @@ -7,8 +7,10 @@ // `undefined` when the changeset file has not been committed yet (a local // `changeset version` run), in which case the suffix is omitted. // -// `getDependencyReleaseLine` is a verbatim port of the default implementation, -// so "Updated dependencies" blocks are unchanged. +// "Updated dependencies" blocks follow the same `()` convention. The +// default implementation emits one `- Updated dependencies []` line +// per changeset, which repeats the line when several changesets share a commit; +// this one emits a single line listing every contributing commit instead. const SHA_LENGTH = 7; module.exports = { @@ -38,7 +40,7 @@ module.exports = { .map((changeset) => changeset.commit.slice(0, SHA_LENGTH)) ), ]; - const suffix = shas.length > 0 ? ` (${shas.join(', ')})` : ''; + const suffix = shas.length > 0 ? ` [${shas.join(', ')}]` : ''; return [ `- Updated dependencies${suffix}`, ...dependenciesUpdated.map( From 482f3ba991402da616e4441b79d2ee5040ea1391 Mon Sep 17 00:00:00 2001 From: zbynekstara Date: Mon, 24 Aug 2026 12:07:17 +0200 Subject: [PATCH 4/5] improve code and comments --- .changeset/changelog.cjs | 64 +++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/.changeset/changelog.cjs b/.changeset/changelog.cjs index 6af2f7c33d..794ca4702a 100644 --- a/.changeset/changelog.cjs +++ b/.changeset/changelog.cjs @@ -1,46 +1,48 @@ -// Changelog line format: `- ()`. -// -// This replaces the default `@changesets/cli/changelog`, which renders the same -// information as a `: ` prefix instead. `changeset.commit` is the -// full SHA of the commit that added the changeset file, resolved by Changesets -// from local git history - no GitHub token or API request is involved. It is -// `undefined` when the changeset file has not been committed yet (a local -// `changeset version` run), in which case the suffix is omitted. -// -// "Updated dependencies" blocks follow the same `()` convention. The -// default implementation emits one `- Updated dependencies []` line -// per changeset, which repeats the line when several changesets share a commit; -// this one emits a single line listing every contributing commit instead. const SHA_LENGTH = 7; +// NOTE: Returns `null` if the changeset has no commit yet (e.g. local) +const shortSha = (changeset) => { + return ((changeset.commit) ? changeset.commit.slice(0, SHA_LENGTH) : null); +} + module.exports = { + // Changelog line format: + // - () + // + // ... getReleaseLine: async (changeset) => { - const [firstLine, ...continuationLines] = changeset.summary - .split('\n') - .map((line) => line.trimEnd()); - const sha = changeset.commit - ? ` (${changeset.commit.slice(0, SHA_LENGTH)})` - : ''; - let releaseLine = `- ${firstLine}${sha}`; + const summaryLines = changeset.summary.split('\n'); + const trimmedLines = summaryLines.map((line) => line.trimEnd()); + const [firstLine, ...continuationLines] = trimmedLines; + + // Omit SHA suffix if the changeset has no commit (`null`) + const sha = shortSha(changeset); + const suffix = ((sha !== null) ? ` (${sha})` : ''); + + // SHA suffix is added only to first line of summary + let releaseLine = `- ${firstLine}${suffix}`; if (continuationLines.length > 0) { releaseLine += `\n${continuationLines.map((line) => ` ${line}`).join('\n')}`; } return releaseLine; }, + // Changelog dependency bump format: + // - Updated dependencies [, ...] + // - + // - <...> getDependencyReleaseLine: async (changesets, dependenciesUpdated) => { if (dependenciesUpdated.length === 0) return ''; - // One line for all contributing commits, not one line per changeset. - // Changesets that are not committed yet contribute no SHA, and a single - // commit adding several changesets is only listed once. - const shas = [ - ...new Set( - changesets - .filter((changeset) => changeset.commit) - .map((changeset) => changeset.commit.slice(0, SHA_LENGTH)) - ), - ]; - const suffix = shas.length > 0 ? ` [${shas.join(', ')}]` : ''; + + // Get one SHA per changeset + const changesetShas = changesets.map((changeset) => shortSha(changeset)); + // Skip changesets with no commit (`null`) + const filteredShas = changesetShas.filter((sha) => (sha !== null)); + // List each commit at most once + const shas = [...new Set(filteredShas)]; + // Omit SHA suffix if there are no commits left after the above logic + const suffix = ((shas.length) > 0 ? ` [${shas.join(', ')}]` : ''); + return [ `- Updated dependencies${suffix}`, ...dependenciesUpdated.map( From 3c61b13c29efb02122905cc4c8aaf6706ad999be Mon Sep 17 00:00:00 2001 From: zbynekstara Date: Tue, 25 Aug 2026 16:05:05 +0200 Subject: [PATCH 5/5] increase sha_length to 8 to match current git log behavior --- .changeset/changelog.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/changelog.cjs b/.changeset/changelog.cjs index 794ca4702a..0402737a40 100644 --- a/.changeset/changelog.cjs +++ b/.changeset/changelog.cjs @@ -1,4 +1,4 @@ -const SHA_LENGTH = 7; +const SHA_LENGTH = 8; // NOTE: Returns `null` if the changeset has no commit yet (e.g. local) const shortSha = (changeset) => {