@@ -62,31 +62,29 @@ internal fun parseConventionalCommit(message: String, lenient: Boolean = false):
6262
6363 if (reader.consumeIf(CCToken .Type .SCOPE_OPEN_PAREN )) {
6464 scope = reader.consume(CCToken .Type .SCOPE )
65- val hasCloseParen = reader.consumeIf(CCToken .Type .SCOPE_CLOSE_PAREN )
6665
67- if (scope.isNullOrBlank()) {
68- if (! lenient && ! hasCloseParen) {
66+ // This message is valid in non-lenient mode:
67+ // 'build( ): updated dev dependencies'
68+ if (scope == null ) {
69+ if (! lenient) {
6970 return ParseResult .Error (" The commit scope is missing or invalid" )
7071 }
7172
72- // These messages are valid:
73- // 'build( ): updated dev dependencies'
73+ // This message is valid in lenient mode:
7474 // 'build(): updated dev dependencies'
75- scope = scope ? : " "
75+ scope = " "
7676 }
7777
78- // In lenient mode this message without closing parenthesis is valid:
79- // 'build(np '
80- if (! lenient && ! hasCloseParen) {
78+ if (! reader.consumeIf(CCToken .Type .SCOPE_CLOSE_PAREN )) {
8179 return ParseResult .Error (" The commit scope is missing the closing parenthesis" )
8280 }
8381 }
8482
8583 val isBreakingChange = reader.consume(CCToken .Type .BREAKING_CHANGE ) != null
8684
87- // In lenient mode this message without a subject separator is valid:
88- // 'build(npm)'
89- if (! reader.consumeIf(CCToken .Type .SEPARATOR ) && ! lenient ) {
85+ // The ':' subject separator is required to recognize a Conventional Commits message,
86+ // even in lenient mode
87+ if (! reader.consumeIf(CCToken .Type .SEPARATOR )) {
9088 return ParseResult .Error (" The ':' separator is missing after the type/scope" )
9189 }
9290
0 commit comments