remote: fix merging two different config levels

This commit is contained in:
Mr. Outis
2020-01-19 01:56:24 -06:00
parent 263e57e5e6
commit efcddb6f5b
2 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -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
+7
View File
@@ -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()