Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Restore old version_info behavior when .git directory is present #101642

Merged
merged 5 commits into from
Jun 8, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/dev/build/lib/version_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import execa from 'execa';
import fs from 'fs';
import { getBuildNumber } from './get_build_number';

interface Options {
Expand All @@ -27,11 +28,12 @@ export async function getVersionInfo({ isRelease, versionQualifier, pkg }: Optio
isRelease ? '' : '-SNAPSHOT'
);

const buildSha = fs.existsSync('.git')
spalger marked this conversation as resolved.
Show resolved Hide resolved
? await execa('git', ['rev-parse', 'HEAD']).stdout
brianseeders marked this conversation as resolved.
Show resolved Hide resolved
: process.env.GIT_COMMIT || process.env.BUILDKITE_COMMIT;

return {
buildSha:
process.env.GIT_COMMIT ||
process.env.BUILDKITE_COMMIT ||
(await execa('git', ['rev-parse', 'HEAD'])).stdout,
buildSha,
buildVersion,
buildNumber: await getBuildNumber(),
};
Expand Down