From 2d1db3864fb9536e476c0995245a0cfd3990838c Mon Sep 17 00:00:00 2001 From: Mads Jon Nielsen Date: Fri, 1 Aug 2025 13:05:56 +0200 Subject: [PATCH] Print error.message after warning message in git-data.ts --- src/git-data.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/git-data.ts b/src/git-data.ts index d6e309e9c..3400ab365 100644 --- a/src/git-data.ts +++ b/src/git-data.ts @@ -59,11 +59,12 @@ export class GitData { try { await Promise.all(promises); - } catch (e) { + } catch (e: any) { if (e instanceof AssertionError) { return writeStreams.stderr(chalk`{yellow ${e.message}}\n`); } writeStreams.stderr(chalk`{yellow Using fallback git commit data}\n`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); } } @@ -73,9 +74,11 @@ export class GitData { this.branches.default = gitRemoteDefaultBranch.replace("origin/", ""); } catch (e: any) { if (e.stderr === "fatal: ref refs/remotes/origin/HEAD is not a symbolic ref") { - writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`. The default remote branch can be set via \`git remote set-head origin \`}`); + writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`. The default remote branch can be set via \`git remote set-head origin \`\n}`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); } else { writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`.\n}`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); } } } @@ -138,12 +141,13 @@ export class GitData { this.remote.schema = "git"; this.remote.port = port; } - } catch (e) { + } catch (e: any) { if (e instanceof AssertionError) { writeStreams.stderr(chalk`{yellow ${e.message}}\n`); return; } writeStreams.stderr(chalk`{yellow Using fallback git remote data}\n`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); } } @@ -152,8 +156,9 @@ export class GitData { const gitUsernamePromise = Utils.spawn(["git", "config", "user.name"], cwd).then(({stdout}) => { this.user.GITLAB_USER_NAME = stdout.trimEnd(); - }).catch(() => { + }).catch((e) => { writeStreams.stderr(chalk`{yellow Using fallback git user.name}\n`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); }); promises.push(gitUsernamePromise); @@ -161,15 +166,17 @@ export class GitData { const email = stdout.trimEnd(); this.user.GITLAB_USER_EMAIL = email; this.user.GITLAB_USER_LOGIN = email.replace(/@.*/, ""); - }).catch(() => { + }).catch((e) => { writeStreams.stderr(chalk`{yellow Using fallback git user.email}\n`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); }); promises.push(gitEmailPromise); const osUidPromise = Utils.spawn(["id", "-u"], cwd).then(({stdout}) => { this.user.GITLAB_USER_ID = stdout.trimEnd(); - }).catch(() => { + }).catch((e) => { writeStreams.stderr(chalk`{yellow Using fallback linux user id}\n`); + writeStreams.stderr(chalk`{yellow ${e.message}\n}`); }); promises.push(osUidPromise);