diff --git a/dvc/repo/data.py b/dvc/repo/data.py index 26884c25b..2d84361ee 100644 --- a/dvc/repo/data.py +++ b/dvc/repo/data.py @@ -161,7 +161,6 @@ def _git_info(scm: "Base", untracked_files: str = "all") -> GitInfo: unstaged=unstaged, untracked=untracked, is_empty=empty_repo, - # TODO: fix is_dirty when untracked_files="no" is_dirty=any([staged, unstaged, untracked]), ) @@ -244,8 +243,8 @@ def _diff_head_to_index( class Status(TypedDict): not_in_cache: List[str] - committed: Dict[str, Any] - uncommitted: Dict[str, Any] + committed: Dict[str, List[str]] + uncommitted: Dict[str, List[str]] untracked: List[str] unchanged: List[str] git: GitInfo diff --git a/tests/func/test_data_status.py b/tests/func/test_data_status.py index 89f9a15a7..47508e23b 100644 --- a/tests/func/test_data_status.py +++ b/tests/func/test_data_status.py @@ -20,12 +20,10 @@ def test_file(M, tmp_dir, dvc, scm): remove(tmp_dir / "foo") expected = { + **EMPTY_STATUS, "committed": {"modified": ["foo"]}, "uncommitted": {"deleted": ["foo"]}, "git": M.dict(), - "not_in_cache": [], - "unchanged": [], - "untracked": [], } assert dvc.data_status() == expected assert dvc.data_status(granular=True) == expected @@ -39,12 +37,10 @@ def test_directory(M, tmp_dir, dvc, scm): tmp_dir.gen("untracked", "untracked") assert dvc.data_status() == { + **EMPTY_STATUS, "committed": {"modified": [join("dir", "")]}, "uncommitted": {"modified": [join("dir", "")]}, "git": M.dict(), - "not_in_cache": [], - "unchanged": [], - "untracked": [], } assert dvc.data_status(granular=True, untracked_files="all") == { @@ -123,8 +119,6 @@ def test_skip_uncached_pipeline_outputs(tmp_dir, dvc, run_copy_metrics): def test_output_with_newly_added_stage(tmp_dir, dvc): dvc.stage.add(deps=["bar"], outs=["foo"], name="copy", cmd="cp foo bar") - # assert dvc.data_status() == {**EMPTY_STATUS, "not_in_cache": ["foo"]} - # TODO: discuss what the output should be assert dvc.data_status() == EMPTY_STATUS assert dvc.data_status(granular=True) == EMPTY_STATUS @@ -178,16 +172,10 @@ def test_missing_cache_workspace_exists(M, tmp_dir, dvc, scm): assert dvc.data_status(granular=True, untracked_files="all") == { **EMPTY_STATUS, "untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"), - # "committed": { - # "added": M.unordered( - # "foobar", join("dir", "foo"), join("dir", "bar") - # )}, "committed": {"added": M.unordered("foobar", join("dir", ""))}, "uncommitted": { "unknown": M.unordered(join("dir", "foo"), join("dir", "bar")) }, - # even though we don't have cache obj, we can repurpose - # what we have in the workspace "not_in_cache": M.unordered( "foobar", join("dir", ""), @@ -230,7 +218,6 @@ def test_git_committed_missing_cache_workspace_exists(M, tmp_dir, dvc, scm): **EMPTY_STATUS, "not_in_cache": M.unordered("foobar", join("dir", "")), "git": M.dict(), - # TODO: clarify what is unchanged "unchanged": M.unordered("foobar", join("dir", "")), } assert dvc.data_status(granular=True) == { @@ -243,7 +230,6 @@ def test_git_committed_missing_cache_workspace_exists(M, tmp_dir, dvc, scm): "unknown": M.unordered(join("dir", "foo"), join("dir", "bar")) }, "git": M.dict(), - # TODO: clarify what is unchanged "unchanged": M.unordered("foobar", join("dir", "")), } diff --git a/tests/unit/command/test_data_status.py b/tests/unit/command/test_data_status.py index 649ba4df7..08bc8cb3b 100644 --- a/tests/unit/command/test_data_status.py +++ b/tests/unit/command/test_data_status.py @@ -14,15 +14,21 @@ from tests.func.parsing.test_errors import escape_ansi def mocked_status(): yield Status( not_in_cache=["notincache"], - committed={"added": ["dir/bar", "dir/foo"]}, + committed={ + "added": ["dir/bar", "dir/foo"], + "deleted": ["dir/baz"], + "modified": ["dir/foobar"], + "unknown": ["dir/unknown1"], + }, uncommitted={ "added": ["dir/baz"], "modified": ["dir/bar"], "deleted": ["dir/foobar"], + "unknown": ["dir2/unknown2"], }, untracked=["untracked"], unchanged=["dir/foo"], - git={"is_dirty": True}, + git={"is_dirty": True, "is_empty": False}, ) @@ -113,6 +119,8 @@ DVC committed changes: (git commit the corresponding dvc files to update the repo) added: dir/bar added: dir/foo + deleted: dir/baz + modified: dir/foobar DVC uncommitted changes: (use "dvc commit ..." to track changes)