Skip to content

Commit 6b28137

Browse files
committed
fix: only one prefix when multiple
1 parent a566003 commit 6b28137

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/scripts/release-notes.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,28 @@ function normalizeTitleForNotes(title) {
8282
// Remove leading emoji or :emoji: (one or more)
8383
t = t.replace(/^([\s\p{Emoji_Presentation}\p{Extended_Pictographic}]+|(:[a-zA-Z0-9_+-]+:)+)\s*/u, '');
8484

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);
85+
// Match bracket prefix like [Feat, Enhancement]
86+
const match = t.match(/^\[([^\]]+)\]/);
8787
if (match) {
88-
const prefix = match[1].toLowerCase();
89-
t = t.replace(match[0], `[${prefix.charAt(0).toUpperCase() + prefix.slice(1)}] `);
88+
// Take only the first prefix
89+
const firstPrefix = match[1].split(',')[0].trim();
90+
// Keep the rest of the title unchanged
91+
t = `[${firstPrefix}]` + t.slice(match[0].length);
92+
return t;
93+
}
94+
95+
// Match single-word prefix like chore:, feat:, etc.
96+
const match2 = t.match(/^(bug|feat|enhancement|refactor|docs|test|chore|task|composite|ux\/ui)[:\s-]+/i);
97+
if (match2) {
98+
const prefix = match2[1].toLowerCase();
99+
t = t.replace(match2[0], `[${prefix.charAt(0).toUpperCase() + prefix.slice(1)}] `);
90100
}
91101

92102
return t;
93103
}
94104

105+
106+
95107
// --- Fetch all closed PRs ---
96108
async function getAllPRs({ owner, repo, base }) {
97109
const perPage = 100;

0 commit comments

Comments
 (0)