mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-23 02:40:49 -05:00
allow dolt init on dolt repo with just config.json (#8838)
This commit is contained in:
Vendored
+4
-1
@@ -145,8 +145,11 @@ func (dcc *DoltCliConfig) createLocalConfigAt(dir string, vals map[string]string
|
||||
}
|
||||
|
||||
path := filepath.Join(dir, getLocalConfigPath())
|
||||
cfg, err := config.NewFileConfig(path, dcc.fs, vals)
|
||||
if exists, _ := dcc.fs.Exists(path); exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg, err := config.NewFileConfig(path, dcc.fs, vals)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+2
-1
@@ -499,7 +499,8 @@ func (dEnv *DoltEnv) createDirectories(dir string) (string, error) {
|
||||
}
|
||||
|
||||
if len(entries) == 1 {
|
||||
if !entries[0].IsDir() || entries[0].Name() != TmpDirName {
|
||||
entry := entries[0]
|
||||
if (entry.IsDir() && entry.Name() != TmpDirName) || (!entry.IsDir() && entry.Name() != configFile) {
|
||||
return "", fmt.Errorf(".dolt directory already exists at '%s'", dir)
|
||||
}
|
||||
} else if len(entries) != 0 {
|
||||
|
||||
@@ -59,6 +59,28 @@ teardown() {
|
||||
assert_valid_repository
|
||||
}
|
||||
|
||||
@test "init: explicit local configuration for config file" {
|
||||
set_dolt_user "baz", "baz@bash.com"
|
||||
|
||||
mkdir .dolt
|
||||
|
||||
dolt config --add user.name foo
|
||||
dolt config --add user.email foo@bar.com
|
||||
|
||||
run dolt config --local --get user.name
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "foo" ]] || false
|
||||
|
||||
run dolt config --local --get user.email
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "foo@bar.com" ]] || false
|
||||
|
||||
run dolt init
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
assert_valid_repository
|
||||
}
|
||||
|
||||
@test "init: explicit local configuration for name and email" {
|
||||
set_dolt_user "baz", "baz@bash.com"
|
||||
|
||||
@@ -263,7 +285,7 @@ teardown() {
|
||||
|
||||
mkdir -p dbdir/.dolt
|
||||
cd dbdir
|
||||
touch .dolt/config.json
|
||||
touch .dolt/not_config.json
|
||||
run dolt init
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ ".dolt directory already exists" ]] || false
|
||||
|
||||
Reference in New Issue
Block a user