@@ -39,17 +39,25 @@ function pollByCommitThenStatus (owner, repoName, prId) {
3939 return console . error ( `! ${ prInfo } Got error when retrieving GitHub commits for PR` , err . stack )
4040 }
4141
42- const lastSha = commitMetas . pop ( ) . sha
43- pollTravisBuildBySha ( { owner, repoName, prId, lastSha } )
44- console . log ( `* ${ prInfo } Started polling Travis for build by commit ${ lastSha . substr ( 0 , 7 ) } ` )
42+ const lastCommitMeta = commitMetas . pop ( )
43+ const lastCommit = {
44+ sha : lastCommitMeta . sha ,
45+ date : lastCommitMeta . commit . committer . date
46+ }
47+
48+ pollTravisBuildBySha ( { owner, repoName, prId, lastCommit } )
49+ console . log ( `* ${ prInfo } Started polling Travis for build by commit ${ lastCommit . sha . substr ( 0 , 7 ) } ` )
4550 } )
4651}
4752
4853function pollTravisBuildBySha ( options , checkNumber ) {
4954 const createGhStatus = createGhStatusFn ( options )
5055 const prInfo = prInfoStr ( options )
51- const shaToMatch = options . lastSha
52- const prToMatch = options . prId
56+ const toMatch = {
57+ sha : options . lastCommit . sha ,
58+ date : options . lastCommit . date ,
59+ prId : options . prId
60+ }
5361
5462 checkNumber = checkNumber || 1
5563
@@ -64,7 +72,10 @@ function pollTravisBuildBySha (options, checkNumber) {
6472 }
6573
6674 const matchingCommit = res . commits . find ( ( commit ) => {
67- return commit . sha === shaToMatch || commit . pull_request_number === prToMatch
75+ const matchesShaOrPr = commit . sha === toMatch . sha || commit . pull_request_number === toMatch . prId
76+ const matchesCommitDate = commit . committed_at === toMatch . date
77+
78+ return matchesCommitDate && matchesShaOrPr
6879 } )
6980 if ( ! matchingCommit ) {
7081 console . warn ( `! ${ prInfo } Travis hasn't picked up last commit yet, will do check #${ checkNumber + 1 } in 30 seconds` )
0 commit comments