mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
metrics/params: show: add hide_workspace flag
This commit is contained in:
@@ -11,14 +11,9 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs):
|
||||
a_rev = a_rev or "HEAD"
|
||||
b_rev = b_rev or "workspace"
|
||||
|
||||
metrics = repo.metrics.show(*args, **kwargs, revs=[a_rev, b_rev])
|
||||
|
||||
# workspace may have been replaced by active branch
|
||||
workspace_rev = (a_rev == "workspace") or (b_rev == "workspace")
|
||||
if workspace_rev and "workspace" not in metrics:
|
||||
active_branch = repo.scm.active_branch()
|
||||
if active_branch in metrics:
|
||||
metrics["workspace"] = metrics[active_branch]
|
||||
metrics = repo.metrics.show(
|
||||
*args, **kwargs, revs=[a_rev, b_rev], hide_workspace=False
|
||||
)
|
||||
|
||||
old = metrics.get(a_rev, {}).get("data", {})
|
||||
new = metrics.get(b_rev, {}).get("data", {})
|
||||
|
||||
+12
-10
@@ -124,6 +124,7 @@ def show(
|
||||
revs=None,
|
||||
all_commits=False,
|
||||
onerror=None,
|
||||
hide_workspace=True,
|
||||
):
|
||||
if onerror is None:
|
||||
onerror = onerror_collect
|
||||
@@ -142,16 +143,17 @@ def show(
|
||||
repo, targets, rev, recursive, onerror=onerror
|
||||
)
|
||||
|
||||
# Hide workspace metrics if they are the same as in the active branch
|
||||
try:
|
||||
active_branch = repo.scm.active_branch()
|
||||
except (SCMError, NoSCMError):
|
||||
# SCMError - detached head
|
||||
# NoSCMError - no repo case
|
||||
pass
|
||||
else:
|
||||
if res.get("workspace") == res.get(active_branch):
|
||||
res.pop("workspace", None)
|
||||
if hide_workspace:
|
||||
# Hide workspace metrics if they are the same as in the active branch
|
||||
try:
|
||||
active_branch = repo.scm.active_branch()
|
||||
except (SCMError, NoSCMError):
|
||||
# SCMError - detached head
|
||||
# NoSCMError - no repo case
|
||||
pass
|
||||
else:
|
||||
if res.get("workspace") == res.get(active_branch):
|
||||
res.pop("workspace", None)
|
||||
|
||||
errored = errored_revisions(res)
|
||||
if errored:
|
||||
|
||||
@@ -11,14 +11,9 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs):
|
||||
a_rev = a_rev or "HEAD"
|
||||
b_rev = b_rev or "workspace"
|
||||
|
||||
params = repo.params.show(*args, **kwargs, revs=[a_rev, b_rev])
|
||||
|
||||
# workspace may have been replaced by active branch
|
||||
workspace_rev = (a_rev == "workspace") or (b_rev == "workspace")
|
||||
if workspace_rev and "workspace" not in params:
|
||||
active_branch = repo.scm.active_branch()
|
||||
if active_branch in params:
|
||||
params["workspace"] = params[active_branch]
|
||||
params = repo.params.show(
|
||||
*args, **kwargs, revs=[a_rev, b_rev], hide_workspace=False
|
||||
)
|
||||
|
||||
old = params.get(a_rev, {}).get("data", {})
|
||||
new = params.get(b_rev, {}).get("data", {})
|
||||
|
||||
+12
-10
@@ -144,6 +144,7 @@ def show(
|
||||
deps=False,
|
||||
onerror: Callable = None,
|
||||
stages=None,
|
||||
hide_workspace=True,
|
||||
):
|
||||
if onerror is None:
|
||||
onerror = onerror_collect
|
||||
@@ -165,16 +166,17 @@ def show(
|
||||
if params:
|
||||
res[branch] = params
|
||||
|
||||
# Hide workspace params if they are the same as in the active branch
|
||||
try:
|
||||
active_branch = repo.scm.active_branch()
|
||||
except (SCMError, NoSCMError):
|
||||
# SCMError - detached head
|
||||
# NoSCMError - no repo case
|
||||
pass
|
||||
else:
|
||||
if res.get("workspace") == res.get(active_branch):
|
||||
res.pop("workspace", None)
|
||||
if hide_workspace:
|
||||
# Hide workspace params if they are the same as in the active branch
|
||||
try:
|
||||
active_branch = repo.scm.active_branch()
|
||||
except (SCMError, NoSCMError):
|
||||
# SCMError - detached head
|
||||
# NoSCMError - no repo case
|
||||
pass
|
||||
else:
|
||||
if res.get("workspace") == res.get(active_branch):
|
||||
res.pop("workspace", None)
|
||||
|
||||
errored = errored_revisions(res)
|
||||
if errored:
|
||||
|
||||
Reference in New Issue
Block a user