gc: add --skip-failed

This commit is contained in:
dberenbaum
2023-12-20 00:21:23 +02:00
committed by Ruslan Kuprieiev
parent 7821e126fe
commit 827f9a7f03
6 changed files with 59 additions and 14 deletions
+11 -1
View File
@@ -7,7 +7,7 @@ import textwrap
import pytest
from dvc.cli import main
from dvc.exceptions import CollectCacheError, InvalidArgumentError
from dvc.exceptions import CollectCacheError, InvalidArgumentError, RevCollectionError
from dvc.fs import LocalFileSystem
from dvc.utils.fs import remove
from dvc_data.hashfile.db.local import LocalHashFileDB
@@ -439,3 +439,13 @@ def test_gc_logging(caplog, dvc, good_and_bad_cache):
assert "Removed 3 objects from repo cache." in caplog.text
assert "No unused 'local' cache to remove." in caplog.text
assert "No unused 'legacy' cache to remove." in caplog.text
def test_gc_skip_failed(tmp_dir, dvc):
with open("dvc.yaml", mode="w") as f:
f.write("\ninvalid")
with pytest.raises(RevCollectionError):
dvc.gc(force=True, workspace=True)
dvc.gc(force=True, workspace=True, skip_failed=True)
+2
View File
@@ -26,6 +26,7 @@ def test_(dvc, scm, mocker):
"--projects",
"project1",
"project2",
"--skip-failed",
]
)
assert cli_args.func == CmdGC
@@ -51,6 +52,7 @@ def test_(dvc, scm, mocker):
num=None,
not_in_remote=False,
dry=True,
skip_failed=True,
)
cli_args = parse_args(["gc"])