Skip to content

Commit 4b495e2

Browse files
authored
fix: escape regex backslashes in release-it config for scoped commits (#1964)
**Closes:** #1963 ### Description of Changes Commits with scopes (e.g., `docs(adr):`, `fix(auth):`) were not appearing in [GitHub release changelogs](https://github.com/NASA-IMPACT/veda-ui/releases/tag/v6.20.3). The issue seems to be caused by the regex in `.release-it.js` thats using single backslashes inside a template literal passed to `new RegExp()`. So things like `\(` was interpreted as `(` (a grouping operator) instead of a literal parenthesis. Double-escaping the backslashes should fix the pattern so scoped conv commits are matched correctly. ### Notes & Questions About Changes _{Add additonal notes and outstanding questions here related to changes in this pull request}_ ### Validation / Testing Tested locally by running this utility in my terminal: ``` node -e " const config = require('./.release-it.js'); const releaseNotes = config.github.releaseNotes; const changelog = 'feat: add feature\nfix(auth): fix login bug\ndocs(adr): update ADR'; console.log(releaseNotes({ changelog })); " ``` Before fix: Only feat: add feature appears in output After fix: All three commits appear, including scoped ones (fix(auth):, docs(adr):)
2 parents 1836cbc + 3020622 commit 4b495e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.release-it.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function groupCommitsByCategory(logs) {
2222
// Loop through each prefix to find conventional commit pattern ex. feat: , feat(card):, feat(card)! including some edge cases
2323
Object.entries(prefixes).forEach(([prefix, category]) => {
2424
const regex = new RegExp(
25-
`^(${prefix}(\([\w\-]+\))?!?: [^\r\n]+((\s)((\s)[^\r\n]+)+)*)(\s?)$`
25+
`^(${prefix}(\\([\\w\\-]+\\))?!?: [^\\r\\n]+((\\s)((\\s)[^\\r\\n]+)+)*)(\\s?)$`
2626
);
2727
const matches = logs.filter((l) => l.match(regex));
2828
grouped[category] = [...matches, ...grouped[category]];

0 commit comments

Comments
 (0)