mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
output: check push in get_used_objs
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
b550c5e625
commit
6e02dddabd
@@ -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. "
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -93,6 +93,7 @@ def push(
|
||||
recursive=recursive,
|
||||
used_run_cache=used_run_cache,
|
||||
revs=revs,
|
||||
push=True,
|
||||
)
|
||||
|
||||
pushed = len(used_run_cache)
|
||||
|
||||
@@ -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) == {}
|
||||
|
||||
Reference in New Issue
Block a user