Skip to content

Commit

Permalink
[CI] Restore old version_info behavior when .git directory is present (
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseeders authored Jun 8, 2021
1 parent 8c2c83c commit e2d75c2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 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,9 @@
*/

import execa from 'execa';
import fs from 'fs';
import { join } from 'path';
import { REPO_ROOT } from '@kbn/utils';
import { getBuildNumber } from './get_build_number';

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

const buildSha = fs.existsSync(join(REPO_ROOT, '.git'))
? (await execa('git', ['rev-parse', 'HEAD'], { cwd: REPO_ROOT })).stdout
: 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

0 comments on commit e2d75c2

Please sign in to comment.