Skip to content

Commit

Permalink
fix: reduce ambiguity of merge-regex patterns
Browse files Browse the repository at this point in the history
The branch-name patterns used in the merge-commit regex's are now
constraint to the allowed characters in git branch names. This
improves overall performance of the regex matcher.
  • Loading branch information
Kevin-de-Jong committed Jun 17, 2024
1 parent 049cd96 commit 8c65a37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export function getFooterElementsFromParagraph(
* @returns True if the subject is a common merge pattern, false otherwise
*/
function subjectIsMergePattern(subject: string): boolean {
const githubMergeRegex = /^Merge pull request #(\d+) from '?(.*)'?$/;
const bitbucketMergeRegex = /^Merged in '?(.*)'? \(pull request #(\d+)\)$/;
const gitlabMergeRegex = /^Merge( remote-tracking)? branch '?(.*?)'? into '?(.*?)'?$/;
const githubMergeRegex = /^Merge pull request #(\d+) from '?([a-zA-Z0-9_./-]+)'?$/;
const bitbucketMergeRegex = /^Merged in '?([a-zA-Z0-9_./-]+)'? \(pull request #(\d+)\)$/;
const gitlabMergeRegex = /^Merge( remote-tracking)? branch '?([a-zA-Z0-9_./-]+)'?? into '?([a-zA-Z0-9_./-]+)'?$/;

return githubMergeRegex.test(subject) || bitbucketMergeRegex.test(subject) || gitlabMergeRegex.test(subject);
}
Expand Down

0 comments on commit 8c65a37

Please sign in to comment.