Merge pull request #703 from Luca-Timo/ci/whatsnew-highlights-workflow
ci(whatsnew): generate release highlights via GitHub Models
This commit is contained in:
@@ -14,14 +14,35 @@
|
||||
|
||||
const MAX_BULLETS = 8;
|
||||
|
||||
/**
|
||||
* Decode the handful of HTML entities release-please escapes into changelog
|
||||
* text (a raw "/s/<slug>" in a commit subject lands as "/s/<slug>").
|
||||
* Without this the banner shows the literal entity, since React renders text
|
||||
* nodes verbatim. `&` is decoded last so "&lt;" stays "<".
|
||||
*/
|
||||
function decodeEntities(s) {
|
||||
return s
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/�*39;|�*27;|'/gi, "'")
|
||||
.replace(/&/g, '&');
|
||||
}
|
||||
|
||||
/** Strip list markers, conventional-commit scope, and trailing PR/sha links. */
|
||||
function cleanBullet(line) {
|
||||
return line
|
||||
return decodeEntities(line
|
||||
.replace(/^\s*[-*]\s+/, '') // "- " / "* " marker
|
||||
.replace(/^\*\*([^:*]+):\*\*\s*/, '') // "**scope:** " prefix
|
||||
.replace(/\s*\(\[[^\]]*\]\([^)]*\)\)/g, '') // " ([#41](url))" / " ([sha](url))"
|
||||
.replace(/\s*\(#\d+\)/g, '') // bare " (#41)"
|
||||
.replace(/`/g, '')
|
||||
.replace(/`/g, ''))
|
||||
// Drop a trailing "— implementation detail" clause so a release highlight
|
||||
// reads as the headline ("branded URL shortener"), not the commit subject
|
||||
// ("branded URL shortener — /s/<slug> with OG injection"). Em dash only, so
|
||||
// hyphenated words ("mark-paid") are untouched. Skipped if it would empty
|
||||
// the bullet (i.e. nothing before the dash).
|
||||
.replace(/^(.+?\S)\s+—\s+.*$/, '$1')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user