Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dvc/command/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def run(self):

class CmdRemoteDefault(CmdRemoteConfig):
def run(self):
self.remote_config.set_default(
self.args.name, unset=self.args.unset, level=self.args.level
)
if self.args.name is None and not self.args.unset:
name = self.remote_config.get_default(level=self.args.level)
print(name)
else:
self.remote_config.set_default(
self.args.name, unset=self.args.unset, level=self.args.level
)
return 0


Expand Down
5 changes: 5 additions & 0 deletions dvc/remote/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,8 @@ def set_default(self, name, unset=False, level=None):
self.config.set(
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, name, level=level
)

def get_default(self, level=None):
return self.config.get(
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, level=level
)
7 changes: 7 additions & 0 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ def test(self):
self.assertEqual(default, None)


def test_show_default(dvc_repo, capsys):
assert main(["remote", "default", "foo"]) == 0
assert main(["remote", "default"]) == 0
out, _ = capsys.readouterr()
assert out == "foo\n"


class TestRemoteShouldHandleUppercaseRemoteName(TestDvc):
upper_case_remote_name = "UPPERCASEREMOTE"

Expand Down