1
1
import { isUndefined } from "lodash-es" ;
2
- import { sync as parser } from "conventional-commits-parser" ;
3
- import filter from "conventional-commits-filter" ;
2
+ import { CommitParser } from "conventional-commits-parser" ;
3
+ import { filterRevertedCommitsSync } from "conventional-commits-filter" ;
4
4
import debugFactory from "debug" ;
5
5
import loadParserConfig from "./lib/load-parser-config.js" ;
6
6
import loadReleaseRules from "./lib/load-release-rules.js" ;
@@ -31,7 +31,8 @@ export async function analyzeCommits(pluginConfig, context) {
31
31
const config = await loadParserConfig ( pluginConfig , context ) ;
32
32
let releaseType = null ;
33
33
34
- filter (
34
+ const parser = new CommitParser ( config ) ;
35
+ const filteredCommits = filterRevertedCommitsSync (
35
36
commits
36
37
. filter ( ( { message, hash } ) => {
37
38
if ( ! message . trim ( ) ) {
@@ -41,8 +42,15 @@ export async function analyzeCommits(pluginConfig, context) {
41
42
42
43
return true ;
43
44
} )
44
- . map ( ( { message, ...commitProps } ) => ( { rawMsg : message , message, ...commitProps , ...parser ( message , config ) } ) )
45
- ) . every ( ( { rawMsg, ...commit } ) => {
45
+ . map ( ( { message, ...commitProps } ) => ( {
46
+ rawMsg : message ,
47
+ message,
48
+ ...commitProps ,
49
+ ...parser . parse ( message ) ,
50
+ } ) )
51
+ ) ;
52
+
53
+ for ( const { rawMsg, ...commit } of filteredCommits ) {
46
54
logger . log ( `Analyzing commit: %s` , rawMsg ) ;
47
55
let commitReleaseType ;
48
56
@@ -71,11 +79,10 @@ export async function analyzeCommits(pluginConfig, context) {
71
79
72
80
// Break loop if releaseType is the highest
73
81
if ( releaseType === RELEASE_TYPES [ 0 ] ) {
74
- return false ;
82
+ break ;
75
83
}
84
+ }
76
85
77
- return true ;
78
- } ) ;
79
86
logger . log ( "Analysis of %s commits complete: %s release" , commits . length , releaseType || "no" ) ;
80
87
81
88
return releaseType ;
0 commit comments