Skip to content

Commit a566003

Browse files
committed
fix: normalize title for release notes
1 parent 3563138 commit a566003

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

.github/scripts/release-notes.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function classifyTitle(title) {
6565
}
6666

6767
// Single-word prefix like chore:, feat:
68-
match = t.match(/^(bug|feat|enhancement|refactor|docs|test|chore|task|composite|ux\/ui|proposal|idea|discussion)[:\s-]+/i);
68+
match = t.match(/^(bug|feat|enhancement|refactor|docs|test|chore|task|composite|ux\/ui)[:\s-]+/i);
6969
if (match) {
7070
const prefix = match[1].toLowerCase();
7171
return PREFIX_MAP[prefix] || "Other";
@@ -74,19 +74,19 @@ function classifyTitle(title) {
7474
return "Other";
7575
}
7676

77-
// --- Normalize title for display (keep all prefixes in brackets as-is) ---
77+
// --- Normalize title for release notes ---
78+
// Convert emoji + chore: → [Chore], feat: → [Feat], etc.
7879
function normalizeTitleForNotes(title) {
7980
let t = title.trim();
8081

81-
// Match leading emoji + optional :emoji: + optional text prefix like chore:, feat:, etc.
82-
const match = t.match(/^([\s\p{Emoji_Presentation}\p{Extended_Pictographic}]+|(:[a-zA-Z0-9_+-]+:)+)\s*(bug|feat|enhancement|refactor|docs|test|chore|task|composite|ux\/ui)[:\s-]+/i);
82+
// Remove leading emoji or :emoji: (one or more)
83+
t = t.replace(/^([\s\p{Emoji_Presentation}\p{Extended_Pictographic}]+|(:[a-zA-Z0-9_+-]+:)+)\s*/u, '');
84+
85+
// Match leading word prefix like chore:, feat:, etc.
86+
const match = t.match(/^(bug|feat|enhancement|refactor|docs|test|chore|task|composite|ux\/ui)[:\s-]+/i);
8387
if (match) {
84-
const prefix = match[3].toLowerCase();
85-
const sectionName = PREFIX_MAP[prefix];
86-
if (sectionName) {
87-
// Replace everything matched with [Prefix] (first letter capitalized)
88-
t = t.replace(match[0], `[${prefix.charAt(0).toUpperCase() + prefix.slice(1)}] `);
89-
}
88+
const prefix = match[1].toLowerCase();
89+
t = t.replace(match[0], `[${prefix.charAt(0).toUpperCase() + prefix.slice(1)}] `);
9090
}
9191

9292
return t;
@@ -274,7 +274,7 @@ async function main() {
274274
console.log(`✅ Release processing completed`);
275275
}
276276

277-
// --- Run ---
277+
// Run
278278
main().catch(err => {
279279
console.error("Error:", err);
280280
process.exit(1);

0 commit comments

Comments
 (0)