File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -157,10 +157,19 @@ async function getPayloadResults(database: firebaseAdmin.database.Database, comm
157
157
function getCommitFromPreviousPayloadUpload ( ) : string {
158
158
if ( isTravisMasterBuild ( ) ) {
159
159
const commitRange = process . env [ 'TRAVIS_COMMIT_RANGE' ] ;
160
+ // In some situations Travis will include multiple commits in a single Travis Job. This means
161
+ // that we can't just resolve the previous commit by using the parent commit of HEAD.
162
+ // By resolving the amount of commits inside of the current Travis Job we can figure out
163
+ // how many commits before HEAD the last Travis Job ran.
160
164
const commitCount = spawnSync ( 'git' , [ 'rev-list' , '--count' , commitRange ] ) . stdout
161
165
. toString ( ) . trim ( ) ;
166
+ // With the amount of commits inside of the current Travis Job we can query Git to print
167
+ // the SHA of the commit that ran before this Travis Job was created.
162
168
return spawnSync ( 'git' , [ 'rev-parse' , `HEAD~${ commitCount } ` ] ) . stdout . toString ( ) . trim ( ) ;
163
169
} else {
170
+ // Travis applies the changes of Pull Requests in new branches. This means that resolving
171
+ // the commit, that previously ran on the target branch (mostly "master"), can be done
172
+ // by just loading the SHA of the most recent commit in the target branch.
164
173
return spawnSync ( 'git' , [ 'rev-parse' , process . env [ 'TRAVIS_BRANCH' ] ] ) . stdout . toString ( ) . trim ( ) ;
165
174
}
166
175
}
You can’t perform that action at this time.
0 commit comments