Skip to content

Commit

Permalink
feat: clean title with scope
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed May 22, 2024
1 parent ba6dae8 commit d29bb44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/events/pr-handlers/actions/utils/prTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe('cleanTitle', () => {
expect(cleanTitle('Feat/add something', true)).toBe('feat: add something');
});

it('should clean slash with scope', () => {
expect(cleanTitle('Feat/scope/add something', true)).toBe(
'feat(scope): add something',
);
});

it('should clean ;', () => {
expect(cleanTitle('feat;add something', true)).toBe('feat: add something');
});
Expand Down
4 changes: 4 additions & 0 deletions src/events/pr-handlers/actions/utils/prTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const cleanTitle = (
}

return cleaned
.replace(
/^([A-Za-z]+)\/([A-Z_a-z-]+)\/\s*/,
(s, arg1, arg2) => `${arg1.toLowerCase()}(${arg2}): `,
)
.replace(/^([A-Za-z]+)[/:;]\s*/, (s, arg1) => `${arg1.toLowerCase()}: `)
.replace(/\s+(-\s*)?[()[\]]\s*no[\s-]*isss?ue\s*[()[\]]$/i, ' [no issue]')
.replace(/^Revert "([^"]+)"( \[no issue])?$/, 'revert: $1$2')
Expand Down

0 comments on commit d29bb44

Please sign in to comment.