diff --git a/dvc/command/diff.py b/dvc/command/diff.py index bc96a38f9..d717bf2fd 100644 --- a/dvc/command/diff.py +++ b/dvc/command/diff.py @@ -111,14 +111,12 @@ class CmdDiff(CmdBase): if not sum(summary.values()): return None - fmt = ( - "files summary: {added} added, {deleted} deleted," - " {renamed} renamed, {modified} modified" + states_summary = ", ".join( + f"{summary[state]} {state}" + for state in states + if summary[state] > 0 ) - if not hide_missing: - fmt += ", {not in cache} not in cache" - - ui.write(fmt.format_map(summary)) + ui.write("files summary:", states_summary) def run(self): from dvc.exceptions import DvcException diff --git a/tests/unit/command/test_diff.py b/tests/unit/command/test_diff.py index 023ceccb2..70877c33d 100644 --- a/tests/unit/command/test_diff.py +++ b/tests/unit/command/test_diff.py @@ -48,8 +48,7 @@ def test_default(mocker, capsys): "Renamed:\n" " data{sep}file_old -> data{sep}file_new\n" "\n" - "files summary: 1 added, 0 deleted, " - "1 renamed, 0 modified, 0 not in cache" + "files summary: 1 added, 1 renamed" ).format(sep=os.path.sep) in capsys.readouterr()[0] @@ -99,8 +98,7 @@ def test_show_hash(mocker, capsys): " CCCCCCCC..DDDDDDDD file1\n" " AAAAAAAA..BBBBBBBB file2\n" "\n" - "files summary: 0 added, 2 deleted, " - "1 renamed, 2 modified, 0 not in cache" + "files summary: 2 deleted, 1 renamed, 2 modified" ) in out @@ -350,6 +348,6 @@ def test_hide_missing(mocker, capsys): "Renamed:\n" " file_old -> file_new\n" "\n" - "files summary: 1 added, 0 deleted, 1 renamed, 0 modified" + "files summary: 1 added, 1 renamed" ) in out assert "not in cache" not in out