Skip to content

Commit c5bae26

Browse files
committed
!squash projects.git.obtain: Start moving over, needs logging in real time
1 parent 6390f39 commit c5bae26

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

libvcs/projects/git.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from typing import Dict, Optional, TypedDict, Union
2222
from urllib import parse as urlparse
2323

24+
from libvcs.cmd.git import Git
2425
from libvcs.types import StrPath
2526

2627
from .. import exc
@@ -312,24 +313,26 @@ def set_remotes(self, overwrite: bool = False):
312313

313314
def obtain(self, *args, **kwargs):
314315
"""Retrieve the repository, clone if doesn't exist."""
315-
self.ensure_dir()
316-
317-
url = self.url
316+
clone_kwargs = {}
318317

319-
cmd = ["clone", "--progress"]
320318
if self.git_shallow:
321-
cmd.extend(["--depth", "1"])
319+
clone_kwargs["depth"] = 1
322320
if self.tls_verify:
323-
cmd.extend(["-c", "http.sslVerify=false"])
324-
cmd.extend([url, self.dir])
321+
clone_kwargs["c"] = "http.sslVerify=false"
325322

326323
self.log.info("Cloning.")
327-
self.run(cmd, log_in_real_time=True)
324+
325+
git = Git(dir=self.dir)
326+
327+
# Needs to log to std out, e.g. log_in_real_time
328+
git.clone(url=self.url, progress=True, make_parents=True, **clone_kwargs)
328329

329330
self.log.info("Initializing submodules.")
331+
330332
self.run(["submodule", "init"], log_in_real_time=True)
331-
cmd = ["submodule", "update", "--recursive", "--init"]
332-
self.run(cmd, log_in_real_time=True)
333+
self.run(
334+
["submodule", "update", "--recursive", "--init"], log_in_real_time=True
335+
)
333336

334337
self.set_remotes(overwrite=True)
335338

0 commit comments

Comments
 (0)