@@ -31,9 +31,13 @@ async function commitlint(context) {
3131 // Paginate all PR commits
3232 return paginate ( pullRequests . getCommits ( pull ) , async ( { data } ) => {
3333 // empty summary
34- const report = { valid : true , commits : { } }
34+ const report = { valid : true , commits : [ ] }
3535 const { rules } = await load ( config )
3636
37+ // Keep counters
38+ let errorsCount = 0
39+ let warnsCount = 0
40+
3741 // Iterates over all commits
3842 for ( const d of data ) {
3943 const { valid, errors, warnings } = await lint ( d . commit . message , rules )
@@ -42,21 +46,24 @@ async function commitlint(context) {
4246 }
4347
4448 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 } )
4654 }
4755 }
4856
49- const { summary, message } = format ( report )
50-
5157 // Final status
5258 await repos . createStatus ( {
5359 ...statusInfo ,
5460 state : report . valid ? 'success' : 'failure' ,
55- description : summary
61+ description : `found ${ errorsCount } problems, ${ warnsCount } warnings`
5662 } )
5763
5864 // Write a comment with the details (if any)
59- if ( message ) {
65+ if ( errorsCount > 0 || warnsCount > 0 ) {
66+ const message = format ( report . commits )
6067 await issues . createComment ( { ...pull , body : message } )
6168 }
6269 } )
0 commit comments