mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
metrics: don't show working tree if it is clean
This commit is contained in:
@@ -298,6 +298,15 @@ def show(
|
||||
if not res and not any(targets):
|
||||
raise NoMetricsError()
|
||||
|
||||
# Hide working tree metrics if they are the same as in the active branch
|
||||
try:
|
||||
active_branch = repo.scm.active_branch()
|
||||
except TypeError:
|
||||
pass # Detached head
|
||||
else:
|
||||
if res.get("working tree") == res.get(active_branch):
|
||||
res.pop("working tree", None)
|
||||
|
||||
missing = set(targets) - found
|
||||
|
||||
if missing:
|
||||
|
||||
@@ -83,6 +83,25 @@ class TestMetricsBase(TestDvcGit):
|
||||
self.dvc.scm.checkout("master")
|
||||
|
||||
|
||||
def test_show_dirty(tmp_dir, scm, dvc):
|
||||
tmp_dir.gen("metric", "master")
|
||||
dvc.run(metrics_no_cache=["metric"], overwrite=True)
|
||||
tmp_dir.scm_add(["metric", "metric.dvc"], commit="add metric")
|
||||
|
||||
tmp_dir.gen("metric", "dirty")
|
||||
|
||||
assert dvc.metrics.show(["metric"]) == {"": {"metric": "dirty"}}
|
||||
|
||||
assert dvc.metrics.show(["metric"], all_branches=True) == {
|
||||
"working tree": {"metric": "dirty"},
|
||||
"master": {"metric": "master"},
|
||||
}
|
||||
|
||||
assert dvc.metrics.show(["metric"], all_tags=True) == {
|
||||
"working tree": {"metric": "dirty"}
|
||||
}
|
||||
|
||||
|
||||
class TestMetrics(TestMetricsBase):
|
||||
def test_show(self):
|
||||
ret = self.dvc.metrics.show(["metric"], all_branches=True)
|
||||
@@ -708,7 +727,6 @@ class TestCachedMetrics(TestDvcGit):
|
||||
"master": {"metrics.json": ["master"]},
|
||||
"one": {"metrics.json": ["one"]},
|
||||
"two": {"metrics.json": ["two"]},
|
||||
"working tree": {"metrics.json": ["two"]},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -722,7 +740,6 @@ class TestCachedMetrics(TestDvcGit):
|
||||
"master": {"metrics.json": ["master"]},
|
||||
"one": {"metrics.json": ["one"]},
|
||||
"two": {"metrics.json": ["two"]},
|
||||
"working tree": {"metrics.json": ["two"]},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user