Don't link to github if fake commit hash

This commit is contained in:
Lim Chee Aun 2023-12-25 20:05:56 +08:00
parent 976f0a5592
commit a539cfea0a
2 changed files with 16 additions and 11 deletions

View file

@ -576,6 +576,7 @@ function Settings({ onClose }) {
}
}}
/>{' '}
{!__FAKE_COMMIT_HASH__ && (
<span class="ib insignificant">
(
<a
@ -587,6 +588,7 @@ function Settings({ onClose }) {
</a>
)
</span>
)}
</p>
)}
</section>

View file

@ -17,12 +17,14 @@ const {
const now = new Date();
let commitHash;
let fakeCommitHash = false;
try {
commitHash = execSync('git rev-parse --short HEAD').toString().trim();
} catch (error) {
// If error, means git is not installed or not a git repo (could be downloaded instead of git cloned)
// Fallback to random hash which should be different on every build run 🤞
commitHash = uid();
fakeCommitHash = true;
}
const rollbarCode = fs.readFileSync(
@ -38,6 +40,7 @@ export default defineConfig({
define: {
__BUILD_TIME__: JSON.stringify(now),
__COMMIT_HASH__: JSON.stringify(commitHash),
__FAKE_COMMIT_HASH__: fakeCommitHash,
},
server: {
host: true,