mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
brancher: include working tree in every method call
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from dvc.scm.tree import WorkingTree
|
||||
|
||||
|
||||
def brancher( # noqa: E302
|
||||
self, branches=None, all_branches=False, tags=None, all_tags=False
|
||||
):
|
||||
@@ -24,11 +27,8 @@ def brancher( # noqa: E302
|
||||
|
||||
scm = self.scm
|
||||
|
||||
if self.scm.is_dirty():
|
||||
from dvc.scm.tree import WorkingTree
|
||||
|
||||
self.tree = WorkingTree(self.root_dir)
|
||||
yield "Working Tree"
|
||||
self.tree = WorkingTree(self.root_dir)
|
||||
yield "working tree"
|
||||
|
||||
if all_branches:
|
||||
branches = scm.list_branches()
|
||||
@@ -36,9 +36,7 @@ def brancher( # noqa: E302
|
||||
if all_tags:
|
||||
tags = scm.list_tags()
|
||||
|
||||
if branches is None and not (all_tags and not all_branches):
|
||||
revs.extend([scm.active_branch()])
|
||||
elif branches is not None:
|
||||
if branches is not None:
|
||||
revs.extend(branches)
|
||||
|
||||
if tags is not None:
|
||||
|
||||
@@ -706,6 +706,7 @@ class TestCachedMetrics(TestDvc):
|
||||
"master": {"metrics.json": ["master"]},
|
||||
"one": {"metrics.json": ["one"]},
|
||||
"two": {"metrics.json": ["two"]},
|
||||
"working tree": {"metrics.json": ["two"]},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -719,6 +720,7 @@ class TestCachedMetrics(TestDvc):
|
||||
"master": {"metrics.json": ["master"]},
|
||||
"one": {"metrics.json": ["one"]},
|
||||
"two": {"metrics.json": ["two"]},
|
||||
"working tree": {"metrics.json": ["two"]},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -829,26 +831,3 @@ class TestShouldDisplayMetricsEvenIfMetricIsMissing(object):
|
||||
in caplog.text
|
||||
)
|
||||
assert 0 == ret
|
||||
|
||||
|
||||
def test_should_not_display_current_branch_on_display_tag(
|
||||
git, dvc_repo, repo_dir
|
||||
):
|
||||
def write_metric_code(metric_filename, metric_value):
|
||||
return "with open('{}', 'w') as fobj:\n fobj.write('{}')".format(
|
||||
metric_filename, metric_value
|
||||
)
|
||||
|
||||
metric_filename = "metric"
|
||||
metric_stage = metric_filename + Stage.STAGE_FILE_SUFFIX
|
||||
code = write_metric_code(metric_filename, 0.5)
|
||||
run_command = 'python -c "{}"'
|
||||
|
||||
dvc_repo.run(cmd=run_command.format(code), metrics=[metric_filename])
|
||||
git.index.add([metric_filename, metric_stage])
|
||||
git.index.commit("first")
|
||||
tag = "v1.0"
|
||||
git.git.tag(tag)
|
||||
|
||||
metrics = dvc_repo.metrics.show(all_tags=True)
|
||||
assert set(metrics.keys()) == {tag}
|
||||
|
||||
Reference in New Issue
Block a user