Skip to content

Commit

Permalink
feat: relax commit message validation to accept commit messages witho…
Browse files Browse the repository at this point in the history
…ut spaces before the description (after `:`)
  • Loading branch information
Salakar committed Jan 7, 2022
1 parent b1eff4d commit ddf7fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/conventional_commit/lib/conventional_commit.dart
Expand Up @@ -16,7 +16,7 @@
*/

final _conventionalCommitRegex = RegExp(
r'^(?<type>build|chore|ci|docs|feat|fix|bug|perf|refactor|revert|style|test)(?<scope>\([a-zA-Z0-9_,\s\*]+\)?((?=:\s)|(?=!:\s)))?(?<breaking>!)?(?<description>:\s.*)?|^(?<merge>Merge \w+)',
r'^(?<type>build|chore|ci|docs|feat|fix|bug|perf|refactor|revert|style|test)(?<scope>\([a-zA-Z0-9_,\s\*]+\)?((?=:\s?)|(?=!:\s?)))?(?<breaking>!)?(?<description>:\s?.*)?|^(?<merge>Merge \w+)',
);

final _breakingChangeRegex =
Expand Down
Expand Up @@ -66,6 +66,14 @@ void main() {
expect(ConventionalCommit.tryParse('custom: new feature'), isNull);
});

test('accepts commit messages with or without a space before description',
() {
expect(ConventionalCommit.tryParse('feat:new thing'), isNotNull);
expect(ConventionalCommit.tryParse('feat(foo):new thing'), isNotNull);
expect(ConventionalCommit.tryParse('feat: new thing'), isNotNull);
expect(ConventionalCommit.tryParse('feat(foo): new thing'), isNotNull);
});

test('correctly handles messages with a `*` scope', () {
final commit = ConventionalCommit.tryParse(commitMessageStarScope);
expect(commit, isNotNull);
Expand Down

0 comments on commit ddf7fb1

Please sign in to comment.