@@ -58,35 +58,24 @@ internal fun parseConventionalCommit(message: String, lenient: Boolean = false):
5858 return ParseResult .Error (" The commit type '$type ' is invalid" )
5959 }
6060
61+ // These messages are valid:
62+ // 'build( ): updated dev dependencies'
63+ // 'build(): updated dev dependencies'
6164 var scope: String? = null
6265
6366 if (reader.consumeIf(CCToken .Type .SCOPE_OPEN_PAREN )) {
64- scope = reader.consume(CCToken .Type .SCOPE )
65- val hasCloseParen = reader.consumeIf(CCToken .Type .SCOPE_CLOSE_PAREN )
67+ scope = reader.consume(CCToken .Type .SCOPE ) ? : " "
6668
67- if (scope.isNullOrBlank()) {
68- if (! lenient && ! hasCloseParen) {
69- return ParseResult .Error (" The commit scope is missing or invalid" )
70- }
71-
72- // These messages are valid:
73- // 'build( ): updated dev dependencies'
74- // 'build(): updated dev dependencies'
75- scope = scope ? : " "
76- }
77-
78- // In lenient mode this message without closing parenthesis is valid:
79- // 'build(np '
80- if (! lenient && ! hasCloseParen) {
69+ if (! reader.consumeIf(CCToken .Type .SCOPE_CLOSE_PAREN )) {
8170 return ParseResult .Error (" The commit scope is missing the closing parenthesis" )
8271 }
8372 }
8473
8574 val isBreakingChange = reader.consume(CCToken .Type .BREAKING_CHANGE ) != null
8675
87- // In lenient mode this message without a subject separator is valid:
88- // 'build(npm)'
89- if (! reader.consumeIf(CCToken .Type .SEPARATOR ) && ! lenient ) {
76+ // The ':' subject separator is required to recognize a Conventional Commits message,
77+ // even in lenient mode
78+ if (! reader.consumeIf(CCToken .Type .SEPARATOR )) {
9079 return ParseResult .Error (" The ':' separator is missing after the type/scope" )
9180 }
9281
0 commit comments