mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
gc: disallow --remote without other flags
This commit is contained in:
committed by
David de la Iglesia Castro
parent
1e538ed87b
commit
f888544554
+1
-1
@@ -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",
|
||||
|
||||
@@ -16,6 +16,9 @@ logger = logging.getLogger(__name__)
|
||||
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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user