Skip to content

Commit 14650c8

Browse files
committed
chore(shortcuts): Clone create_repo_legacy
May remove this later
1 parent d1f16d5 commit 14650c8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

libvcs/shortcuts.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,40 @@ def create_repo_from_pip_url(
8787
return SubversionRepo.from_pip_url(pip_url, **kwargs)
8888
else:
8989
raise InvalidPipURL(pip_url)
90+
91+
92+
def create_repo_legacy(
93+
url, vcs, progress_callback=None, *args, **kwargs
94+
) -> Union[GitRepo, MercurialRepo, SubversionRepo]:
95+
r"""Return a object representation of a VCS repository.
96+
97+
Examples
98+
--------
99+
>>> from libvcs.shortcuts import create_repo_legacy
100+
>>>
101+
>>> r = create_repo(
102+
... url='https://www.github.com/you/myrepo',
103+
... vcs='git',
104+
... repo_dir='/tmp/myrepo'
105+
... )
106+
107+
>>> r.update_repo()
108+
|myrepo| (git) Repo directory for myrepo (git) does not exist @ \
109+
/tmp/myrepo
110+
|myrepo| (git) Cloning.
111+
|myrepo| (git) git clone https://www.github.com/tony/myrepo \
112+
/tmp/myrepo
113+
Cloning into '/tmp/myrepo'...
114+
Checking connectivity... done.
115+
|myrepo| (git) git fetch
116+
|myrepo| (git) git pull
117+
Already up-to-date.
118+
"""
119+
if vcs == "git":
120+
return GitRepo(url, progress_callback=progress_callback, *args, **kwargs)
121+
elif vcs == "hg":
122+
return MercurialRepo(url, progress_callback=progress_callback, *args, **kwargs)
123+
elif vcs == "svn":
124+
return SubversionRepo(url, progress_callback=progress_callback, *args, **kwargs)
125+
else:
126+
raise InvalidVCS("VCS %s is not a valid VCS" % vcs)

0 commit comments

Comments
 (0)