output: check push in get_used_objs

This commit is contained in:
Peter Rowlands
2022-11-18 16:32:29 +09:00
committed by Peter Rowlands (변기호)
parent b550c5e625
commit 6e02dddabd
5 changed files with 24 additions and 0 deletions
+6
View File
@@ -1043,9 +1043,15 @@ class Output:
if not self.use_cache:
return {}
push: bool = kwargs.pop("push", False)
if self.stage.is_repo_import:
if push:
return {}
return self.get_used_external(**kwargs)
if push and not self.can_push:
return {}
if not self.hash_info:
msg = (
"Output '{}'({}) is missing version info. "
+2
View File
@@ -401,6 +401,7 @@ class Repo:
used_run_cache=None,
revs=None,
num=1,
push: bool = False,
):
"""Get the stages related to the given target and collect
the `info` of its outputs.
@@ -435,6 +436,7 @@ class Repo:
jobs=jobs,
recursive=recursive,
with_deps=with_deps,
push=push,
).items():
used[odb].update(objs)
+2
View File
@@ -268,6 +268,7 @@ class Index:
force: bool = False,
recursive: bool = False,
jobs: int = None,
push: bool = False,
) -> "ObjectContainer":
from collections import defaultdict
@@ -281,6 +282,7 @@ class Index:
force=force,
jobs=jobs,
filter_info=filter_info,
push=push,
).items():
used[odb].update(objs)
return used
+1
View File
@@ -93,6 +93,7 @@ def push(
recursive=recursive,
used_run_cache=used_run_cache,
revs=revs,
push=True,
)
pushed = len(used_run_cache)
+13
View File
@@ -51,3 +51,16 @@ def test_from_gitfs_when_pwd_not_in_root(
with wdir.chdir():
assert dvc.used_objs([target], revs=[scm.get_rev()])
def test_used_objs_push(tmp_dir, scm, dvc):
stage = tmp_dir.dvc_gen("foo", "foo")[0]
hash_info = stage.outs[0].hash_info
stage.outs[0].can_push = True
assert stage.get_used_objs(push=False) == {None: {hash_info}}
assert stage.get_used_objs(push=True) == {None: {hash_info}}
stage.outs[0].can_push = False
assert stage.get_used_objs(push=False) == {None: {hash_info}}
assert stage.get_used_objs(push=True) == {}