Skip to content

Commit 8b758ed

Browse files
authored
Merge pull request #21 from andrewmolyuk/fix-release-commit
fix: improve commit transformation to return a shallow copy and filte…
2 parents 1c710d1 + 692e88a commit 8b758ed

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.releaserc.cjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ module.exports = {
1212
writerOpts: {
1313
transform(commit) {
1414
if (!commit) return null
15+
16+
// Filter out merge commits by header
1517
if (commit.header && typeof commit.header === 'string') {
1618
if (commit.header.startsWith('Merge pull request')) return null
1719
if (commit.header.startsWith('Merge branch')) return null
1820
}
1921

22+
// Return a shallow copy instead of mutating the provided object.
23+
// The conventional-changelog writer may provide frozen/immutable commits.
24+
const out = Object.assign({}, commit)
25+
2026
// shorten commit hash for nicer links (7 chars is common)
21-
if (commit.hash && typeof commit.hash === 'string' && commit.hash.length > 7) {
22-
commit.hash = commit.hash.slice(0, 7)
27+
if (out.hash && typeof out.hash === 'string' && out.hash.length > 7) {
28+
out.hash = out.hash.slice(0, 7)
2329
}
2430

25-
return commit
31+
return out
2632
},
2733
},
2834
},

0 commit comments

Comments
 (0)