Toned down the warning message when git is not found

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-11-28 10:00:54 +01:00
parent f5cff08f95
commit 0ffee55010
2 changed files with 17 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Toned down the warning message when git is not found
+12 -6
View File
@@ -55,18 +55,24 @@ export function resolveBaseUrl(config: Config): URL {
async function readBuildInfo() {
const timestamp = Date.now();
let commit = 'unknown';
let commit: string | unknown;
try {
commit = await runPlain('git', 'rev-parse', 'HEAD');
} catch (error) {
console.warn(`WARNING: Failed to read git commit, ${error}`);
// ignore, see below
}
let gitVersion = 'unknown';
let gitVersion: string | unknown;
try {
gitVersion = await runPlain('git', 'describe', '--always');
} catch (error) {
console.warn(`WARNING: Failed to describe git version, ${error}`);
// ignore, see below
}
if (commit === undefined || gitVersion === undefined) {
console.info(
'NOTE: Did not compute git version or commit hash, could not execute the git command line utility',
);
}
const { version: packageVersion } = await fs.readJson(
@@ -75,10 +81,10 @@ async function readBuildInfo() {
return {
cliVersion: version,
gitVersion,
gitVersion: gitVersion ?? 'unknown',
packageVersion,
timestamp,
commit,
commit: commit ?? 'unknown',
};
}