params: fix diff bt active branch and workspace

This commit is contained in:
dberenbaum
2023-01-09 16:57:18 +02:00
committed by Ruslan Kuprieiev
parent c6b602a167
commit 0b192af6f4
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -13,6 +13,12 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs):
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()
params["workspace"] = params[active_branch]
old = params.get(a_rev, {}).get("data", {})
new = params.get(b_rev, {}).get("data", {})
+8
View File
@@ -268,3 +268,11 @@ def test_diff_top_level_params(tmp_dir, dvc, scm, dvcfile, params_file):
"foo": {"diff": 2, "new": 5, "old": 3}
}
}
def test_diff_active_branch_no_changes(tmp_dir, scm, dvc):
tmp_dir.gen("params.yaml", "foo: bar")
dvc.run(cmd="echo params.yaml", params=["foo"], single_stage=True)
scm.add(["params.yaml", "Dvcfile"])
scm.commit("bar")
assert dvc.params.diff(a_rev=tmp_dir.scm.active_branch()) == {}