mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
diff: only show states with values in summary (#6229)
* Fixed diff summary to only show states with values. * Removed redundant comma by using join. * Swithced for loop to generator for better readability. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
pre-commit-ci[bot]
parent
98f7d1e481
commit
9d9ff10be1
+5
-7
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user