Skip to content

Commit bf856cd

Browse files
authored
ci: Modify immutable commit subject via spreading (n8n-io#27467)
1 parent 61a5261 commit bf856cd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.github/scripts/update-changelog.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import createTempFile from 'tempfile';
2-
import { ConventionalChangelog, packagePrefix } from 'conventional-changelog';
2+
import { ConventionalChangelog } from 'conventional-changelog';
33
import { resolve } from 'path';
44
import { createReadStream, createWriteStream } from 'fs';
55
import { dirname } from 'path';
@@ -35,7 +35,15 @@ const changelogStream = new ConventionalChangelog()
3535
// Strip backport information from commit subject, e.g.:
3636
// "Fix something (backport to release-candidate/2.12.x) (#123)" → "Fix something (#123)"
3737
if (commit.subject) {
38-
commit.subject = commit.subject.replace(/\s*\(backport to [^)]+\)/g, '');
38+
// The commit.subject is immutable so we need to recreate the commit object
39+
40+
/** @type { import("conventional-changelog").Commit } */
41+
let newCommit = /** @type { any } */ ({
42+
...commit,
43+
subject: commit.subject.replace(/\s*\(backport to [^)]+\)/g, ''),
44+
});
45+
46+
return newCommit;
3947
}
4048

4149
return commit;

0 commit comments

Comments
 (0)