mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-25 00:54:51 -06:00
add check for nonsense variables in config
This commit is contained in:
@@ -461,6 +461,24 @@ func runMain() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
globalConfig.Iter(func(name, val string) (stop bool) {
|
||||
if _, ok := commands.ConfigOptions[name]; !ok {
|
||||
cli.Println(color.YellowString("Warning: Unknown global config option '%s'. Use `dolt config --global --unset %s` to remove.", name, name))
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
// try verifying contents of local config
|
||||
localConfig, ok := dEnv.Config.GetConfig(env.LocalConfig)
|
||||
if ok {
|
||||
localConfig.Iter(func(name, val string) (stop bool) {
|
||||
if _, ok := commands.ConfigOptions[name]; !ok {
|
||||
cli.Println(color.YellowString("Warning: Unknown local config option '%s'. Use `dolt config --local --unset %s` to remove.", name, name))
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
apr, remainingArgs, subcommandName, err := parseGlobalArgsAndSubCommandName(globalConfig, args)
|
||||
if err == argparser.ErrHelp {
|
||||
doltCommand.PrintUsage("dolt")
|
||||
|
||||
@@ -53,6 +53,25 @@ teardown() {
|
||||
[[ "$output" =~ "Config successfully updated" ]] || false
|
||||
}
|
||||
|
||||
@test "config: warning on cli commands if config has nonsense variables" {
|
||||
dolt config --global --add user.name steph # need to create config_global.json first
|
||||
echo '{"global":"foo"}' > $DOLT_ROOT_PATH/.dolt/config_global.json
|
||||
run dolt version
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "Warning: Unknown global config option 'global'. Use \`dolt config --global --unset global\` to remove." ]] || false
|
||||
|
||||
dolt config --global --add user.email "you@example.com"
|
||||
dolt config --global --add user.name "Your Name"
|
||||
dolt init
|
||||
|
||||
dolt config --local --add user.name steph # need to create config.json first
|
||||
echo '{"local":"bar"}' > .dolt/config.json
|
||||
run dolt config --list
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "Warning: Unknown global config option 'global'. Use \`dolt config --global --unset global\` to remove." ]] || false
|
||||
[[ "$output" =~ "Warning: Unknown local config option 'local'. Use \`dolt config --local --unset local\` to remove." ]] || false
|
||||
}
|
||||
|
||||
@test "config: set a global config variable" {
|
||||
run dolt config --global --add user.name steph
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user