mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-08 02:59:37 -06:00
Fixed bugs in config and some formatting errors
This commit is contained in:
@@ -257,27 +257,26 @@ Run
|
||||
to set your account's default identity.
|
||||
Omit --global to set the identity only in this repository.
|
||||
|
||||
fatal: empty ident name not allowed`
|
||||
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 {
|
||||
ok := true
|
||||
|
||||
_, err := dEnv.Config.GetString(env.UserEmailKey)
|
||||
if err != nil {
|
||||
PrintErr(userNameRequiredError)
|
||||
ok = false
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = dEnv.Config.GetString(env.UserNameKey)
|
||||
if err != nil {
|
||||
PrintErr(userNameRequiredError)
|
||||
ok = false
|
||||
return false
|
||||
}
|
||||
|
||||
return ok
|
||||
return true
|
||||
}
|
||||
|
||||
func (hc SubCommandHandler) printUsage(commandStr string) {
|
||||
|
||||
@@ -76,6 +76,11 @@ func (cmd CommitCmd) 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
|
||||
}
|
||||
|
||||
// Check if the -all param is provided. Stage all tables if so.
|
||||
allFlag := apr.Contains(cli.AllFlag)
|
||||
|
||||
|
||||
@@ -142,17 +142,27 @@ func getOperation(dEnv *env.DoltEnv, setCfgTypes *set.StrSet, args []string, pri
|
||||
return 1
|
||||
}
|
||||
|
||||
cfgTypesSl := setCfgTypes.AsSlice()
|
||||
for _, cfgType := range cfgTypesSl {
|
||||
if _, ok := dEnv.Config.GetConfig(newCfgElement(cfgType)); !ok {
|
||||
cli.PrintErrln(color.RedString("Unable to read config."))
|
||||
var cfg config.ReadableConfig
|
||||
switch setCfgTypes.Size() {
|
||||
case 0:
|
||||
cfg = dEnv.Config
|
||||
case 1:
|
||||
configElement := newCfgElement(setCfgTypes.AsSlice()[0])
|
||||
var ok bool
|
||||
cfg, ok = dEnv.Config.GetConfig(configElement)
|
||||
if !ok {
|
||||
cli.Println(color.RedString("No config found for %s", configElement.String()))
|
||||
return 1
|
||||
}
|
||||
default:
|
||||
// should be impossible due to earlier checks
|
||||
cli.Println(color.RedString("Cannot get more than one config scope at once"))
|
||||
return 1
|
||||
}
|
||||
|
||||
val, err := dEnv.Config.GetString(args[0])
|
||||
val, err := cfg.GetString(args[0])
|
||||
if err != nil {
|
||||
if err == config.ErrConfigParamNotFound {
|
||||
if err != config.ErrConfigParamNotFound {
|
||||
cli.PrintErrln(color.RedString("Unexpected error: %s", err.Error()))
|
||||
}
|
||||
// Not found prints no error but returns status 1
|
||||
|
||||
Reference in New Issue
Block a user