@@ -2,13 +2,14 @@ import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
22import { Context } from 'probot' ;
33import { Config } from '~common/types' ;
44import { getUserContributorsCacheKey } from '~helpers' ;
5- import { CacheService } from '~services' ;
5+ import { AppService , CacheService , GitHubService } from '~services' ;
66
77export class ReviewSkipConditions {
88 constructor (
99 private readonly context : Context < 'pull_request' > ,
1010 private readonly config : Config ,
1111 private readonly cacheService : CacheService ,
12+ private readonly appService : AppService ,
1213 private readonly apiKey : string
1314 ) { }
1415
@@ -24,12 +25,28 @@ export class ReviewSkipConditions {
2425 this . isMerged ( ) ,
2526 this . isUserIgnored ( ) ,
2627 this . isContributorOnly ( ) ,
27- this . isAuthorOnly ( )
28+ this . isAuthorOnly ( ) ,
29+ this . isCoAuthoredWithBot ( )
2830 ] ;
2931
3032 return ( await Promise . all ( skipChecks ) ) . some ( Boolean ) ;
3133 }
3234
35+ private async isCoAuthoredWithBot ( ) : Promise < boolean > {
36+ if ( this . context . payload . action === 'synchronize' ) {
37+ const commitSha = this . context . payload . after ;
38+ const commit = await GitHubService . getCommit ( commitSha , this . context ) ;
39+ const { message } = commit . data . commit ;
40+ const login = this . appService . getLogin ( ) ;
41+ const email = this . appService . getEmail ( ) ;
42+ const coAuthoredMessage = `${ login } <${ email } >` ;
43+
44+ return message . toLowerCase ( ) . includes ( coAuthoredMessage . toLowerCase ( ) ) ;
45+ }
46+
47+ return false ;
48+ }
49+
3350 private async isContributorOnly ( ) : Promise < boolean > {
3451 const { 'contributors-only' : contributorsOnly , always } = this . config . review . allow [ 'pull-requests' ] ;
3552
0 commit comments