Skip to content

Commit 5ed26d5

Browse files
authored
Print error.message after warning message in git-data.ts (#1621)
1 parent e406616 commit 5ed26d5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/git-data.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ export class GitData {
5959

6060
try {
6161
await Promise.all(promises);
62-
} catch (e) {
62+
} catch (e: any) {
6363
if (e instanceof AssertionError) {
6464
return writeStreams.stderr(chalk`{yellow ${e.message}}\n`);
6565
}
6666
writeStreams.stderr(chalk`{yellow Using fallback git commit data}\n`);
67+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
6768
}
6869
}
6970

@@ -73,9 +74,11 @@ export class GitData {
7374
this.branches.default = gitRemoteDefaultBranch.replace("origin/", "");
7475
} catch (e: any) {
7576
if (e.stderr === "fatal: ref refs/remotes/origin/HEAD is not a symbolic ref") {
76-
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 <default_branch>\`}`);
77+
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 <default_branch>\`\n}`);
78+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
7779
} else {
7880
writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`.\n}`);
81+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
7982
}
8083
}
8184
}
@@ -138,12 +141,13 @@ export class GitData {
138141
this.remote.schema = "git";
139142
this.remote.port = port;
140143
}
141-
} catch (e) {
144+
} catch (e: any) {
142145
if (e instanceof AssertionError) {
143146
writeStreams.stderr(chalk`{yellow ${e.message}}\n`);
144147
return;
145148
}
146149
writeStreams.stderr(chalk`{yellow Using fallback git remote data}\n`);
150+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
147151
}
148152
}
149153

@@ -152,24 +156,27 @@ export class GitData {
152156

153157
const gitUsernamePromise = Utils.spawn(["git", "config", "user.name"], cwd).then(({stdout}) => {
154158
this.user.GITLAB_USER_NAME = stdout.trimEnd();
155-
}).catch(() => {
159+
}).catch((e) => {
156160
writeStreams.stderr(chalk`{yellow Using fallback git user.name}\n`);
161+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
157162
});
158163
promises.push(gitUsernamePromise);
159164

160165
const gitEmailPromise = Utils.spawn(["git", "config", "user.email"], cwd).then(({stdout}) => {
161166
const email = stdout.trimEnd();
162167
this.user.GITLAB_USER_EMAIL = email;
163168
this.user.GITLAB_USER_LOGIN = email.replace(/@.*/, "");
164-
}).catch(() => {
169+
}).catch((e) => {
165170
writeStreams.stderr(chalk`{yellow Using fallback git user.email}\n`);
171+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
166172
});
167173
promises.push(gitEmailPromise);
168174

169175
const osUidPromise = Utils.spawn(["id", "-u"], cwd).then(({stdout}) => {
170176
this.user.GITLAB_USER_ID = stdout.trimEnd();
171-
}).catch(() => {
177+
}).catch((e) => {
172178
writeStreams.stderr(chalk`{yellow Using fallback linux user id}\n`);
179+
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
173180
});
174181
promises.push(osUidPromise);
175182

0 commit comments

Comments
 (0)