|
22 | 22 | from typing import Dict, Literal, Optional, TypedDict, Union |
23 | 23 | from urllib import parse as urlparse |
24 | 24 |
|
| 25 | +from libvcs.cmd.git import Git |
25 | 26 | from libvcs.types import StrPath |
26 | 27 |
|
27 | 28 | from .. import exc |
@@ -313,24 +314,26 @@ def set_remotes(self, overwrite: bool = False): |
313 | 314 |
|
314 | 315 | def obtain(self, *args, **kwargs): |
315 | 316 | """Retrieve the repository, clone if doesn't exist.""" |
316 | | - self.ensure_dir() |
317 | | - |
318 | | - url = self.url |
| 317 | + clone_kwargs = {} |
319 | 318 |
|
320 | | - cmd = ["clone", "--progress"] |
321 | 319 | if self.git_shallow: |
322 | | - cmd.extend(["--depth", "1"]) |
| 320 | + clone_kwargs["depth"] = 1 |
323 | 321 | if self.tls_verify: |
324 | | - cmd.extend(["-c", "http.sslVerify=false"]) |
325 | | - cmd.extend([url, self.dir]) |
| 322 | + clone_kwargs["c"] = "http.sslVerify=false" |
326 | 323 |
|
327 | 324 | self.log.info("Cloning.") |
328 | | - self.run(cmd, log_in_real_time=True) |
| 325 | + |
| 326 | + git = Git(dir=self.dir) |
| 327 | + |
| 328 | + # Needs to log to std out, e.g. log_in_real_time |
| 329 | + git.clone(url=self.url, progress=True, make_parents=True, **clone_kwargs) |
329 | 330 |
|
330 | 331 | self.log.info("Initializing submodules.") |
| 332 | + |
331 | 333 | self.run(["submodule", "init"], log_in_real_time=True) |
332 | | - cmd = ["submodule", "update", "--recursive", "--init"] |
333 | | - self.run(cmd, log_in_real_time=True) |
| 334 | + self.run( |
| 335 | + ["submodule", "update", "--recursive", "--init"], log_in_real_time=True |
| 336 | + ) |
334 | 337 |
|
335 | 338 | self.set_remotes(overwrite=True) |
336 | 339 |
|
|
0 commit comments