mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-08 10:26:35 -06:00
Updated error message for missing identity to match git
This commit is contained in:
@@ -16,7 +16,6 @@ package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -245,6 +244,22 @@ func CheckEnvIsValid(dEnv *env.DoltEnv) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const (
|
||||
userNameRequiredError = `Author identity unknown
|
||||
|
||||
*** Please tell me who you are.
|
||||
|
||||
Run
|
||||
|
||||
dolt config --global user.email "you@example.com"
|
||||
dolt config --global user.name "Your Name"
|
||||
|
||||
to set your account's default identity.
|
||||
Omit --global to set the identity only in this repository.
|
||||
|
||||
fatal: empty ident name not allowed`
|
||||
)
|
||||
|
||||
// CheckUserNameAndEmail returns true if the user name and email are set for this environment, or prints an error and
|
||||
// returns false if not.
|
||||
func CheckUserNameAndEmail(dEnv *env.DoltEnv) bool {
|
||||
@@ -252,13 +267,13 @@ func CheckUserNameAndEmail(dEnv *env.DoltEnv) bool {
|
||||
|
||||
_, err := dEnv.Config.GetString(env.UserEmailKey)
|
||||
if err != nil {
|
||||
PrintErrln(color.RedString(fmt.Sprintf("No config found for required key %s, use dolt config --add %s <your email>", env.UserEmailKey, env.UserEmailKey)))
|
||||
PrintErr(userNameRequiredError)
|
||||
ok = false
|
||||
}
|
||||
|
||||
_, err = dEnv.Config.GetString(env.UserNameKey)
|
||||
if err != nil {
|
||||
PrintErrln(color.RedString(fmt.Sprintf("No config found for required key %s, use dolt config --add %s <your name>", env.UserNameKey, env.UserNameKey)))
|
||||
PrintErr(userNameRequiredError)
|
||||
ok = false
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,11 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
|
||||
return 1
|
||||
}
|
||||
|
||||
// This command creates a commit, so we need user identity
|
||||
if !cli.CheckUserNameAndEmail(dEnv) {
|
||||
return 1
|
||||
}
|
||||
|
||||
name, _ := apr.GetValue(usernameParamName)
|
||||
email, _ := apr.GetValue(emailParamName)
|
||||
initBranch, _ := apr.GetValue(initBranchParamName)
|
||||
|
||||
@@ -84,6 +84,11 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,
|
||||
return 1
|
||||
}
|
||||
|
||||
// This command may create a commit, so we need user identity
|
||||
if !cli.CheckUserNameAndEmail(dEnv) {
|
||||
return 1
|
||||
}
|
||||
|
||||
var verr errhand.VerboseError
|
||||
if apr.Contains(cli.AbortParam) {
|
||||
mergeActive, err := dEnv.IsMergeActive(ctx)
|
||||
|
||||
@@ -67,6 +67,11 @@ func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string,
|
||||
help, usage := cli.HelpAndUsagePrinters(cli.GetCommandDocumentation(commandStr, commitDocs, ap))
|
||||
apr := cli.ParseArgsOrDie(ap, args, help)
|
||||
|
||||
// This command creates a commit, so we need user identity
|
||||
if !cli.CheckUserNameAndEmail(dEnv) {
|
||||
return 1
|
||||
}
|
||||
|
||||
if apr.NArg() < 1 {
|
||||
usage()
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user