Skip to content

Commit 8a06781

Browse files
committed
Add comments
1 parent 304e2fb commit 8a06781

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/gulp/tasks/payload.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,19 @@ async function getPayloadResults(database: firebaseAdmin.database.Database, comm
157157
function getCommitFromPreviousPayloadUpload(): string {
158158
if (isTravisMasterBuild()) {
159159
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.
160164
const commitCount = spawnSync('git', ['rev-list', '--count', commitRange]).stdout
161165
.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.
162168
return spawnSync('git', ['rev-parse', `HEAD~${commitCount}`]).stdout.toString().trim();
163169
} 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.
164173
return spawnSync('git', ['rev-parse', process.env['TRAVIS_BRANCH']]).stdout.toString().trim();
165174
}
166175
}

0 commit comments

Comments
 (0)