no user.email/user.name error message now shows current values

This commit is contained in:
Git-Lior
2018-09-07 14:40:23 +03:00
parent 1f678697ec
commit 63748f8088
2 changed files with 19 additions and 11 deletions
+3 -1
View File
@@ -1716,7 +1716,9 @@ export class CommandCenter {
break;
case GitErrorCodes.NoUserNameConfigured:
case GitErrorCodes.NoUserEmailConfigured:
message = localize('missing user info', "Make sure that user.email and user.name are configured correctly.\n\n{0}\n{1}",
message = localize('missing user info', "Make sure that user.email and user.name are configured correctly.\n\n{0}\n{1}\n\n{2}\n{3}",
"current user.name: " + err.userName || "",
"current user.email: " + err.userEmail || "",
"git config --global user.email \"you@example.com\"",
"git config --global user.name \"Your Name\"");
break;
+16 -10
View File
@@ -978,20 +978,26 @@ export class Repository {
throw commitErr;
}
try {
await this.run(['config', '--get-all', 'user.name']);
} catch (err) {
err.gitErrorCode = GitErrorCodes.NoUserNameConfigured;
throw err;
}
let userName, userEmail;
try {
await this.run(['config', '--get-all', 'user.email']);
} catch (err) {
err.gitErrorCode = GitErrorCodes.NoUserEmailConfigured;
throw err;
const nameResult = await this.run(['config', '--get-all', 'user.name']);
userName = nameResult.stdout.split('\n').filter(l => !!l).pop();
} catch (err) { }
try {
const emailResult = await this.run(['config', '--get-all', 'user.email']);
userEmail = emailResult.stdout.split('\n').filter(l => !!l).pop();
} catch (err) { }
if (userName && userEmail) {
throw commitErr;
}
commitErr.gitErrorCode = !userName ? GitErrorCodes.NoUserNameConfigured : GitErrorCodes.NoUserEmailConfigured;
commitErr.userName = userName;
commitErr.userEmail = userEmail;
throw commitErr;
}