Skip to content

Commit e2d75c2

Browse files
authored
[CI] Restore old version_info behavior when .git directory is present (#101642)
1 parent 8c2c83c commit e2d75c2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/dev/build/lib/version_info.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88

99
import execa from 'execa';
10+
import fs from 'fs';
11+
import { join } from 'path';
12+
import { REPO_ROOT } from '@kbn/utils';
1013
import { getBuildNumber } from './get_build_number';
1114

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

33+
const buildSha = fs.existsSync(join(REPO_ROOT, '.git'))
34+
? (await execa('git', ['rev-parse', 'HEAD'], { cwd: REPO_ROOT })).stdout
35+
: process.env.GIT_COMMIT || process.env.BUILDKITE_COMMIT || '';
36+
3037
return {
31-
buildSha:
32-
process.env.GIT_COMMIT ||
33-
process.env.BUILDKITE_COMMIT ||
34-
(await execa('git', ['rev-parse', 'HEAD'])).stdout,
38+
buildSha,
3539
buildVersion,
3640
buildNumber: await getBuildNumber(),
3741
};

0 commit comments

Comments
 (0)