Do not use Github API fallback by default
MODIFY
lib/config.js
lib/config.js
@@ -21,19 +21,19 @@ function getNodeVersion () {
return [Number(version[1]), Number(version[2])];
}
-async function updateBuildInfo () {
- const sha = await getGitRev(true);
+async function updateBuildInfo (useGithubApiFallback = false) {
+ const sha = await getGitRev(useGithubApiFallback);
if (!sha) {
return;
}
BUILD_INFO['git-sha'] = sha;
- const built = await getGitTimestamp(sha, true);
+ const built = await getGitTimestamp(sha, useGithubApiFallback);
if (!_.isEmpty(built)) {
BUILD_INFO.built = built;
}
}
-async function getGitRev (useGitHubFallback = false) {
+async function getGitRev (useGithubApiFallback = false) {
if (await fs.exists(path.resolve(rootDir, GIT_META_ROOT))) {
try {
const {stdout} = await exec(GIT_BINARY, ['rev-parse', 'HEAD'], {
@@ -43,7 +43,7 @@ async function getGitRev (useGitHubFallback = false) {
} catch (ign) {}
}
- if (!useGitHubFallback) {
+ if (!useGithubApiFallback) {
return null;
}
@@ -65,7 +65,7 @@ async function getGitRev (useGitHubFallback = false) {
return null;
}
-async function getGitTimestamp (commitSha, useGitHubFallback = false) {
+async function getGitTimestamp (commitSha, useGithubApiFallback = false) {
if (await fs.exists(path.resolve(rootDir, GIT_META_ROOT))) {
try {
const {stdout} = await exec(GIT_BINARY, ['show', '-s', '--format=%ci', commitSha], {
@@ -75,7 +75,7 @@ async function getGitTimestamp (commitSha, useGitHubFallback = false) {
} catch (ign) {}
}
- if (!useGitHubFallback) {
+ if (!useGithubApiFallback) {
return null;
}
@@ -126,7 +126,7 @@ function warnNodeDeprecations () {
}
async function showConfig () {
- await updateBuildInfo();
+ await updateBuildInfo(true);
console.log(JSON.stringify(getBuildInfo())); // eslint-disable-line no-console
}

MODIFY
test/config-specs.js
test/config-specs.js
@@ -34,7 +34,7 @@ describe('Config', function () {
mockFs.expects('exists').atLeast(1).returns(useLocalGit);
buildInfo['git-sha'] = undefined;
buildInfo.built = undefined;
- await updateBuildInfo();
+ await updateBuildInfo(true);
buildInfo.should.be.an('object');
should.exist(buildInfo['git-sha']);
should.exist(buildInfo.built);

Do not use Github API fallback by default (#11506)