feat: enable storing commitHash in env var

This commit is contained in:
zkldi
2022-08-18 03:48:02 +01:00
parent a82641849d
commit d1deeab8de
2 changed files with 11 additions and 3 deletions
+10 -3
View File
@@ -6,6 +6,7 @@ import semver from "semver";
import { execSync } from "child_process";
import fs from "fs";
import path from "path";
import { Environment } from "lib/setup/config";
// As is with all front-facing zkldi projects, the version names for tachi-server
// are from an album I like. In this case, the al(bum is Portishead - Dummy.
@@ -65,9 +66,15 @@ if (!semverInfo) {
let commit: string | null = null;
try {
// This fetches the HEAD of our current running branch. This is useful for debugging.
// Note that git returns this with a trailing newline, so we have to trim that off.
commit = execSync("git rev-parse --short HEAD").toString("utf-8").trim();
if (Environment.commitHash) {
commit = Environment.commitHash;
} else {
// This fetches the HEAD of our current running branch. This is useful for debugging.
// Note that git returns this with a trailing newline, so we have to trim that off.
commit = execSync("git rev-parse --short HEAD").toString("utf-8").trim();
}
} catch (err) {
logger.warn(`Failed to read what commit we're on -- Using null as our commit version.`, {
err,
+1
View File
@@ -300,4 +300,5 @@ export const Environment = {
nodeEnv,
replicaIdentity,
seqUrl,
commitHash: process.env.COMMIT_HASH
};