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
2 changes: 1 addition & 1 deletion dvc/commands/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def add_parser(subparsers, parent_parser):
"--cloud",
action="store_true",
default=False,
help="Collect garbage in remote repository.",
help="Collect garbage in remote storage in addition to local cache.",
)
gc_parser.add_argument(
"-r",
Expand Down
3 changes: 3 additions & 0 deletions dvc/repo/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
def _validate_args(**kwargs):
not_in_remote = kwargs.pop("not_in_remote", None)
cloud = kwargs.pop("cloud", None)
remote = kwargs.pop("remote", None)
if remote and not (cloud or not_in_remote):
raise InvalidArgumentError("`--remote` requires `--cloud` or `--not-in-remote`")
if not_in_remote and cloud:
raise InvalidArgumentError(
"`--not-in-remote` and `--cloud` are mutually exclusive"
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/command/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ def test_(dvc, scm, mocker):
cmd = cli_args.func(cli_args)
with pytest.raises(InvalidArgumentError):
cmd.run()

cli_args = parse_args(["gc", "--cloud", "--not-in-remote"])
cmd = cli_args.func(cli_args)
with pytest.raises(InvalidArgumentError):
cmd.run()

cli_args = parse_args(["gc", "--remote", "myremote"])
cmd = cli_args.func(cli_args)
with pytest.raises(InvalidArgumentError):
cmd.run()