Skip to content

Commit

Permalink
DO NOT MERGE testing ampproject#20216
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Rozenberg committed Jan 9, 2019
1 parent 55534ee commit 9d4fcd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
23 changes: 13 additions & 10 deletions build-system/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ exports.gitMergeBaseLocalMaster = function() {
};

/**
* Returns the merge base at which the PR branch was forked from master when
* running on Travis.
* Returns the merge base of the current branch off of master, regardless of
* the running environment.
* @return {string}
*/
exports.gitMergeBaseTravisMaster = function() {
const commitRange = process.env.TRAVIS_COMMIT_RANGE.split('...');
return getStdout(`git merge-base ${commitRange[0]} ${commitRange[1]}`).trim();
exports.gitMergeBaseMaster = function() {
if (process.env.TRAVIS) {
const commitRange = process.env.TRAVIS_COMMIT_RANGE.split('...');
return getStdout(`git merge-base ${commitRange[0]} ${commitRange[1]}`)
.trim();
}
return exports.gitMergeBaseLocalMaster();
};

/**
* Returns the merge vase of the current branch off of master, regardless of
* the running environment.
* Returns the `master` parent of the merge commit (current HEAD) on Travis.
* @return {string}
*/
exports.gitMergeBaseMaster = function() {
return process.env.TRAVIS ?
exports.gitMergeBaseTravisMaster() : exports.gitMergeBaseLocalMaster();
exports.gitTravisMasterBaseline = function() {
return process.env.TRAVIS_COMMIT_RANGE.split('...')[0];
};

/**
Expand Down
6 changes: 3 additions & 3 deletions build-system/tasks/bundle-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const path = require('path');
const requestPost = BBPromise.promisify(require('request').post);
const url = require('url');
const {getStdout} = require('../exec');
const {gitCommitHash, gitMergeBaseMaster} = require('../git');
const {gitCommitHash, gitTravisMasterBaseline} = require('../git');

const runtimeFile = './dist/v0.js';

Expand Down Expand Up @@ -108,7 +108,7 @@ function isPullRequest() {
* @return {string} the `master` ancestor's bundle size.
*/
async function getAncestorBundleSize() {
const gitBranchPointSha = gitMergeBaseMaster();
const gitBranchPointSha = gitTravisMasterBaseline();
const gitBranchPointShortSha = gitBranchPointSha.substring(0, 7);
log('Branch point from master is', cyan(gitBranchPointShortSha));
return await octokit.repos.getContents(
Expand Down Expand Up @@ -328,7 +328,7 @@ async function skipBundleSize() {
*/
async function reportBundleSize() {
if (isPullRequest()) {
const baseSha = gitMergeBaseMaster();
const baseSha = gitTravisMasterBaseline();
const bundleSize = parseFloat(getGzippedBundleSize());
const commitHash = gitCommitHash();
try {
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/visual-diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const tryConnect = require('try-net-connect');
const {
gitBranchName,
gitCommitterEmail,
gitMergeBaseTravisMaster,
gitTravisMasterBaseline,
} = require('../../git');
const {execOrDie, execScriptAsync} = require('../../exec');
const {log, verifyCssElements} = require('./helpers');
Expand Down Expand Up @@ -100,7 +100,7 @@ function setPercyBranch() {
*/
function setPercyTargetCommit() {
if (process.env.TRAVIS && !argv.master) {
process.env['PERCY_TARGET_COMMIT'] = gitMergeBaseTravisMaster();
process.env['PERCY_TARGET_COMMIT'] = gitTravisMasterBaseline();
}
}

Expand Down

0 comments on commit 9d4fcd2

Please sign in to comment.