mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
worktree push: only index known (tracked) files/dirs in the remote
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
b9bf73f043
commit
e98ca36f39
+22
-2
@@ -94,7 +94,7 @@ def fetch_worktree(
|
||||
def push_worktree(
|
||||
repo: "Repo", remote: "Remote", targets: Optional["TargetType"] = None
|
||||
) -> int:
|
||||
from dvc_data.index import build, checkout
|
||||
from dvc_data.index import checkout
|
||||
|
||||
view = worktree_view(
|
||||
repo.index, push=True, targets=targets, latest_only=remote.worktree
|
||||
@@ -102,7 +102,7 @@ def push_worktree(
|
||||
new_index = view.data["repo"]
|
||||
if remote.worktree:
|
||||
logger.debug("indexing latest worktree for '%s'", remote.path)
|
||||
old_index = build(remote.path, remote.fs)
|
||||
old_index = _build_worktree_index(repo, remote, view)
|
||||
logger.debug("Pushing worktree changes to '%s'", remote.path)
|
||||
else:
|
||||
old_index = None
|
||||
@@ -140,6 +140,26 @@ def push_worktree(
|
||||
return pushed
|
||||
|
||||
|
||||
def _build_worktree_index(
|
||||
repo: "Repo", remote: "Remote", view: "IndexView"
|
||||
) -> "DataIndex":
|
||||
from dvc_data.index import DataIndex
|
||||
from dvc_data.index.build import build_entries
|
||||
|
||||
index = DataIndex()
|
||||
for out in view.outs:
|
||||
_workspace, key = out.index_key
|
||||
parts = out.fs.path.relparts(out.fs_path, repo.root_dir)
|
||||
path = remote.fs.path.join(remote.path, *parts)
|
||||
for entry in build_entries(path, remote.fs):
|
||||
if not entry.key or entry.key == ("",):
|
||||
entry.key = key
|
||||
else:
|
||||
entry.key = key + entry.key
|
||||
index.add(entry)
|
||||
return index
|
||||
|
||||
|
||||
def _update_out_meta(
|
||||
out: "Output", index: Union["DataIndex", "DataIndexView"]
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user