mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 15:28:26 +01:00
remote: fix merging two different config levels
This commit is contained in:
+5
-2
@@ -424,10 +424,13 @@ class Config(object): # pylint: disable=too-many-instance-attributes
|
||||
config.write()
|
||||
|
||||
def validate(self, config=None):
|
||||
d = (config or self.config).dict()
|
||||
ret = copy.deepcopy(self.config)
|
||||
|
||||
if config:
|
||||
ret.merge(config)
|
||||
|
||||
try:
|
||||
return self.COMPILED_SCHEMA(d)
|
||||
return self.COMPILED_SCHEMA(ret.dict())
|
||||
except Invalid as exc:
|
||||
raise ConfigError(str(exc)) from exc
|
||||
|
||||
|
||||
@@ -265,3 +265,10 @@ def test_modify_invalid_key(dvc):
|
||||
|
||||
with pytest.raises(ConfigError, match=r"extra keys not allowed"):
|
||||
remote_config.modify("example", "random_key", "value")
|
||||
|
||||
|
||||
def test_merging_two_levels(tmp_dir, dvc):
|
||||
assert 0 == main(["remote", "add", "test", "https://example.com"])
|
||||
assert 0 == main(["remote", "modify", "--local", "test", "password", "1"])
|
||||
assert "example.com" in (tmp_dir / ".dvc" / "config").read_text()
|
||||
assert "password" in (tmp_dir / ".dvc" / "config.local").read_text()
|
||||
|
||||
Reference in New Issue
Block a user