44from collections .abc import Sequence
55from typing import Any , Literal , Optional , Union
66
7- from libvcs ._internal .run import run
7+ from libvcs ._internal .run import ProgressCallbackProtocol , run
88from libvcs ._internal .types import StrOrBytesPath , StrPath
99
1010_CMD = Union [StrOrBytesPath , Sequence [StrOrBytesPath ]]
1111
1212
1313class 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