Skip to content

Commit 69e54d3

Browse files
committed
chore: read from build/COMMIT_SHA fle as fallback for commit hash
1 parent 2cfb221 commit 69e54d3

File tree

1 file changed

+14
-2
lines changed
  • packages/react-devtools-extensions

1 file changed

+14
-2
lines changed

packages/react-devtools-extensions/utils.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
const {execSync} = require('child_process');
9-
const {readFileSync} = require('fs');
9+
const {existsSync, readFileSync} = require('fs');
1010
const {resolve} = require('path');
1111

1212
const GITHUB_URL = 'https://github.com/facebook/react';
@@ -18,7 +18,19 @@ function getGitCommit() {
1818
.trim();
1919
} catch (error) {
2020
// Mozilla runs this command from a git archive.
21-
// In that context, there is no Git revision.
21+
// In that context, there is no Git context.
22+
// Using the commit hash specified to download-experimental-build.js script as a fallback.
23+
24+
// Try to read from build/COMMIT_SHA file
25+
try {
26+
const commitShaPath = resolve(__dirname, '..', '..', 'build', 'COMMIT_SHA');
27+
if (existsSync(commitShaPath)) {
28+
const commitHash = readFileSync(commitShaPath, 'utf8').trim();
29+
// Return short hash (first 7 characters) to match abbreviated commit hash format
30+
return commitHash.slice(0, 7);
31+
}
32+
} catch (readError) {}
33+
2234
return null;
2335
}
2436
}

0 commit comments

Comments
 (0)