mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
list: don't clone local repos (#5341)
* repo: introduce Repo.open * ls: don't clone local repos
This commit is contained in:
@@ -59,13 +59,17 @@ def external_repo(
|
||||
url=url,
|
||||
scm=None if for_write else Git(root_dir),
|
||||
rev=None if for_write else rev,
|
||||
subrepos=not for_write,
|
||||
uninitialized=True,
|
||||
config=config,
|
||||
repo_factory=make_repo,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
if "subrepos" not in repo_kwargs:
|
||||
repo_kwargs["subrepos"] = True
|
||||
|
||||
if "uninitialized" not in repo_kwargs:
|
||||
repo_kwargs["uninitialized"] = True
|
||||
|
||||
repo = Repo(**repo_kwargs)
|
||||
|
||||
try:
|
||||
|
||||
@@ -202,6 +202,18 @@ class Repo:
|
||||
def __str__(self):
|
||||
return self.url or self.root_dir
|
||||
|
||||
@staticmethod
|
||||
@contextmanager
|
||||
def open(url, *args, **kwargs):
|
||||
if os.path.exists(url):
|
||||
yield Repo(url, *args, **kwargs)
|
||||
return
|
||||
|
||||
from dvc.external_repo import external_repo
|
||||
|
||||
with external_repo(url, *args, **kwargs) as repo:
|
||||
yield repo
|
||||
|
||||
@cached_property
|
||||
def scm(self):
|
||||
from dvc.scm import SCM
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ def ls(
|
||||
"isexec": bool,
|
||||
}
|
||||
"""
|
||||
from dvc.external_repo import external_repo
|
||||
from . import Repo
|
||||
|
||||
with external_repo(url, rev) as repo:
|
||||
with Repo.open(url, rev, subrepos=True, uninitialized=True) as repo:
|
||||
path_info = PathInfo(repo.root_dir)
|
||||
if path:
|
||||
path_info /= path
|
||||
|
||||
Reference in New Issue
Block a user