@@ -31,9 +31,13 @@ async function commitlint(context) {
31
31
// Paginate all PR commits
32
32
return paginate ( pullRequests . getCommits ( pull ) , async ( { data } ) => {
33
33
// empty summary
34
- const report = { valid : true , commits : { } }
34
+ const report = { valid : true , commits : [ ] }
35
35
const { rules } = await load ( config )
36
36
37
+ // Keep counters
38
+ let errorsCount = 0
39
+ let warnsCount = 0
40
+
37
41
// Iterates over all commits
38
42
for ( const d of data ) {
39
43
const { valid, errors, warnings } = await lint ( d . commit . message , rules )
@@ -42,21 +46,24 @@ async function commitlint(context) {
42
46
}
43
47
44
48
if ( errors . length > 0 || warnings . length > 0 ) {
45
- report . commits [ d . sha ] = { errors, warnings }
49
+ // Update counts
50
+ errorsCount += errors . length
51
+ warnsCount += warnings . length
52
+
53
+ report . commits . push ( { sha : d . sha , errors, warnings } )
46
54
}
47
55
}
48
56
49
- const { summary, message } = format ( report )
50
-
51
57
// Final status
52
58
await repos . createStatus ( {
53
59
...statusInfo ,
54
60
state : report . valid ? 'success' : 'failure' ,
55
- description : summary
61
+ description : `found ${ errorsCount } problems, ${ warnsCount } warnings`
56
62
} )
57
63
58
64
// Write a comment with the details (if any)
59
- if ( message ) {
65
+ if ( errorsCount > 0 || warnsCount > 0 ) {
66
+ const message = format ( report . commits )
60
67
await issues . createComment ( { ...pull , body : message } )
61
68
}
62
69
} )
0 commit comments