@@ -794,7 +794,7 @@ def __init__(self, working_dir: Union[None, PathLike] = None):
794
794
self ._environment : Dict [str , str ] = {}
795
795
796
796
# Cached version slots
797
- self ._version_info : Union [Tuple [int , int , int , int ], None ] = None
797
+ self ._version_info : Union [Tuple [int , ... ], None ] = None
798
798
self ._version_info_token : object = None
799
799
800
800
# Cached command slots
@@ -831,10 +831,10 @@ def working_dir(self) -> Union[None, PathLike]:
831
831
return self ._working_dir
832
832
833
833
@property
834
- def version_info (self ) -> Tuple [int , int , int , int ]:
834
+ def version_info (self ) -> Tuple [int , ... ]:
835
835
"""
836
- :return: tuple(int, int, int, int) tuple with integers representing the major,
837
- minor and additional version numbers as parsed from git version.
836
+ :return: tuple with integers representing the major, minor and additional
837
+ version numbers as parsed from git version. Up to four fields are used .
838
838
839
839
This value is generated on demand and is cached.
840
840
"""
@@ -846,16 +846,14 @@ def version_info(self) -> Tuple[int, int, int, int]:
846
846
assert self ._version_info is not None , "Bug: corrupted token-check state"
847
847
return self ._version_info
848
848
849
- # We only use the first 4 numbers, as everything else could be strings in fact (on Windows).
850
- process_version = self ._call_process ("version" ) # Should be as default *args and **kwargs used.
851
- version_numbers = process_version .split (" " )[2 ]
849
+ # Run "git version" and parse it.
850
+ process_version = self ._call_process ("version" )
851
+ version_string = process_version .split (" " )[2 ]
852
+ version_fields = version_string .split ("." )[:4 ]
853
+ self ._version_info = tuple (int (n ) for n in version_fields if n .isdigit ())
852
854
853
- self ._version_info = cast (
854
- Tuple [int , int , int , int ],
855
- tuple (int (n ) for n in version_numbers .split ("." )[:4 ] if n .isdigit ()),
856
- )
855
+ # This value will be considered valid until the next refresh.
857
856
self ._version_info_token = refresh_token
858
-
859
857
return self ._version_info
860
858
861
859
@overload
0 commit comments