Skip to content

Commit 0d0659b

Browse files
committed
refactor(sync[git]): Callback pass-through
1 parent 502a52d commit 0d0659b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
from collections.abc import Sequence
55
from typing import Any, Literal, Optional, Union
66

7-
from libvcs._internal.run import run
7+
from libvcs._internal.run import ProgressCallbackProtocol, run
88
from libvcs._internal.types import StrOrBytesPath, StrPath
99

1010
_CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
1111

1212

1313
class Git:
14-
def __init__(self, *, dir: StrPath) -> None:
14+
progress_callback: Optional[ProgressCallbackProtocol] = None
15+
16+
def __init__(
17+
self,
18+
*,
19+
dir: StrPath,
20+
progress_callback: Optional[ProgressCallbackProtocol] = None,
21+
) -> None:
1522
"""Lite, typed, pythonic wrapper for git(1).
1623
1724
Parameters
@@ -31,6 +38,8 @@ def __init__(self, *, dir: StrPath) -> None:
3138
else:
3239
self.dir = pathlib.Path(dir)
3340

41+
self.progress_callback = progress_callback
42+
3443
# Initial git-submodule
3544
self.submodule = GitSubmoduleCmd(dir=self.dir, cmd=self)
3645
self.remote = GitRemoteCmd(dir=self.dir, cmd=self)
@@ -201,6 +210,9 @@ def stringify(v: Any) -> str:
201210
if no_optional_locks is True:
202211
cli_args.append("--no-optional-locks")
203212

213+
if self.progress_callback is not None:
214+
kwargs["callback"] = self.progress_callback
215+
204216
return run(args=cli_args, **kwargs)
205217

206218
def clone(

0 commit comments

Comments
 (0)