Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\A(?:(?:^(?<type>feat|fix|ci|chore|docs|test|style|refactor|build|perf|revert)(?:\((?<scope>.+)\))?(?<breaking>!)?:\s(?<subject>.{3,})$)(?:(?:(?<BLANK_LINE>\n^$\n)(?<body>(?:^.{3,}$\n?)+))?(?<BLANK_LINE2>\n^$\n)(?:(?<breaking_change>^BREAKING\sCHANGE:\s[\s\w]+$)\n)?(?:(?<footer>^\w+:\s.+)))?\n?|)\Z
/
gm

Description

Conventional Commits is a specification for adding human and machine readable meaning to commit messages.

CommitCheck is a GitHub app that ensures commit messages, PR titles and PR descriptions are consistent and contain required information.

However, CommitCheck supports only ruby regular expression. So, I had to write yet another version of conventional commits regex.

Submitted by https://github.com/CCXXXI - 2 years ago