@@ -9,6 +9,7 @@ const COMMITLINT = process.env.TRAVIS_COMMITLINT_BIN;
9
9
const REQUIRED = [
10
10
'TRAVIS_COMMIT' ,
11
11
'TRAVIS_COMMIT_RANGE' ,
12
+ 'TRAVIS_EVENT_TYPE' ,
12
13
'TRAVIS_REPO_SLUG' ,
13
14
'TRAVIS_PULL_REQUEST_SLUG'
14
15
] ;
@@ -17,6 +18,7 @@ const COMMIT = process.env.TRAVIS_COMMIT;
17
18
const REPO_SLUG = process . env . TRAVIS_REPO_SLUG ;
18
19
const PR_SLUG = process . env . TRAVIS_PULL_REQUEST_SLUG || REPO_SLUG ;
19
20
const RANGE = process . env . TRAVIS_COMMIT_RANGE ;
21
+ const IS_PR = process . env . TRAVIS_EVENT_TYPE === 'pull_request' ;
20
22
21
23
main ( ) . catch ( err => {
22
24
console . log ( err ) ;
@@ -32,20 +34,21 @@ async function main() {
32
34
// Make base and source available as dedicated remotes
33
35
await Promise . all ( [
34
36
( ) => fetch ( { name : 'base' , url : `https://github.com/${ REPO_SLUG } .git` } ) ,
35
- ( ) => fetch ( { name : 'source' , url : `https://github.com/${ PR_SLUG } .git` } )
37
+ IS_PR
38
+ ? ( ) => fetch ( { name : 'source' , url : `https://github.com/${ PR_SLUG } .git` } )
39
+ : async ( ) => { }
36
40
] ) ;
37
41
38
42
// Restore stashed changes if any
39
43
await pop ( ) ;
40
44
41
45
// Lint all commits in TRAVIS_COMMIT_RANGE if available
42
- if ( RANGE ) {
46
+ if ( IS_PR && RANGE ) {
43
47
const [ start , end ] = RANGE . split ( '.' ) . filter ( Boolean ) ;
44
48
await lint ( [ '--from' , start , '--to' , end ] ) ;
49
+ } else {
50
+ await lint ( [ '--from' , COMMIT ] ) ;
45
51
}
46
-
47
- // Always lint the triggering commit indicated by TRAVIS_COMMIT
48
- await lint ( [ '--from' , COMMIT ] ) ;
49
52
}
50
53
51
54
async function git ( args , options ) {
0 commit comments