|
21 | 21 | from typing import Dict, Optional, TypedDict, Union
|
22 | 22 | from urllib import parse as urlparse
|
23 | 23 |
|
| 24 | +from libvcs.cmd.git import Git |
24 | 25 | from libvcs.types import StrPath
|
25 | 26 |
|
26 | 27 | from .. import exc
|
@@ -312,24 +313,26 @@ def set_remotes(self, overwrite: bool = False):
|
312 | 313 |
|
313 | 314 | def obtain(self, *args, **kwargs):
|
314 | 315 | """Retrieve the repository, clone if doesn't exist."""
|
315 |
| - self.ensure_dir() |
316 |
| - |
317 |
| - url = self.url |
| 316 | + clone_kwargs = {} |
318 | 317 |
|
319 |
| - cmd = ["clone", "--progress"] |
320 | 318 | if self.git_shallow:
|
321 |
| - cmd.extend(["--depth", "1"]) |
| 319 | + clone_kwargs["depth"] = 1 |
322 | 320 | if self.tls_verify:
|
323 |
| - cmd.extend(["-c", "http.sslVerify=false"]) |
324 |
| - cmd.extend([url, self.dir]) |
| 321 | + clone_kwargs["c"] = "http.sslVerify=false" |
325 | 322 |
|
326 | 323 | 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) |
328 | 329 |
|
329 | 330 | self.log.info("Initializing submodules.")
|
| 331 | + |
330 | 332 | 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 | + ) |
333 | 336 |
|
334 | 337 | self.set_remotes(overwrite=True)
|
335 | 338 |
|
|
0 commit comments