mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
remote: modify: fix --unset (#3939)
https://discordapp.com/channels/485586884165107732/563406153334128681/717474697721413686 Fixes https://github.com/iterative/dvc/issues/3938
This commit is contained in:
@@ -62,7 +62,11 @@ class CmdRemoteModify(CmdRemote):
|
||||
def run(self):
|
||||
with self.config.edit(self.args.level) as conf:
|
||||
self._check_exists(conf)
|
||||
conf["remote"][self.args.name][self.args.option] = self.args.value
|
||||
section = conf["remote"][self.args.name]
|
||||
if self.args.unset:
|
||||
section.pop(self.args.option, None)
|
||||
else:
|
||||
section[self.args.option] = self.args.value
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -273,6 +273,29 @@ def test_remote_modify_validation(dvc):
|
||||
assert unsupported_config not in config[f'remote "{remote_name}"']
|
||||
|
||||
|
||||
def test_remote_modify_unset(dvc):
|
||||
assert main(["remote", "add", "-d", "myremote", "gdrive://test/test"]) == 0
|
||||
config = configobj.ConfigObj(dvc.config.files["repo"])
|
||||
assert config['remote "myremote"'] == {"url": "gdrive://test/test"}
|
||||
|
||||
assert (
|
||||
main(["remote", "modify", "myremote", "gdrive_client_id", "something"])
|
||||
== 0
|
||||
)
|
||||
config = configobj.ConfigObj(dvc.config.files["repo"])
|
||||
assert config['remote "myremote"'] == {
|
||||
"url": "gdrive://test/test",
|
||||
"gdrive_client_id": "something",
|
||||
}
|
||||
|
||||
assert (
|
||||
main(["remote", "modify", "myremote", "gdrive_client_id", "--unset"])
|
||||
== 0
|
||||
)
|
||||
config = configobj.ConfigObj(dvc.config.files["repo"])
|
||||
assert config['remote "myremote"'] == {"url": "gdrive://test/test"}
|
||||
|
||||
|
||||
def test_remote_modify_default(dvc):
|
||||
remote_repo = "repo_level"
|
||||
remote_local = "local_level"
|
||||
|
||||
Reference in New Issue
Block a user