Skip to content

Commit

Permalink
feat: support no issue with revert in cleanTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Jun 3, 2023
1 parent d1b8974 commit 5557d9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/events/pr-handlers/actions/utils/prTitle.test.ts
Expand Up @@ -56,6 +56,14 @@ describe('cleanTitle', () => {
).toBe('revert: chore(deps): update node.js to v8.14');
});

it('should write correct revert with no issue', () => {
expect(
cleanTitle(
'Revert "chore(deps): update node.js to v8.14 (#296)" [no issue]',
),
).toBe('revert: chore(deps): update node.js to v8.14 [no issue]');
});

it('should clean no issue', () => {
expect(cleanTitle('feat: add something [no issue[')).toBe(
'feat: add something [no issue]',
Expand Down
4 changes: 2 additions & 2 deletions src/events/pr-handlers/actions/utils/prTitle.ts
Expand Up @@ -6,6 +6,6 @@ export const cleanTitle = (title: string): string =>
(s, arg1, arg2) => ` ${arg1.toUpperCase()}-${arg2}`,
)
.replace(/^([A-Za-z]+)[/:]\s*/, (s, arg1) => `${arg1.toLowerCase()}: `)
.replace(/^Revert "([^"]+)"$/, 'revert: $1')
.replace(/\s+[()[\]]\s*no[\s-]*isss?ue\s*[()[\]]$/i, ' [no issue]')
.replace(/^(revert:.*)(\s+\(#\d+\))$/, '$1');
.replace(/^Revert "([^"]+)"( \[no issue])?$/, 'revert: $1$2')
.replace(/^(revert:.*)(\s+\(#\d+\))( \[no issue])?$/, '$1$3');

0 comments on commit 5557d9f

Please sign in to comment.