@@ -20,9 +20,7 @@ class InvalidBuildOptions(ValueError):
2020 """Raised when a git version output is in an unexpected format.
2121
2222 >>> InvalidBuildOptions("...")
23- Traceback (most recent call last):
24- ...
25- libvcs.cmd.git.InvalidBuildOptions: Unexpected git version output format: ...
23+ InvalidBuildOptions('Unexpected git version output format: ...')
2624 """
2725
2826 def __init__ (self , version : str , * args : object ) -> None :
@@ -1787,18 +1785,12 @@ def config(
17871785 def version (
17881786 self ,
17891787 * ,
1790- build_options : bool | None = None ,
17911788 # libvcs special behavior
17921789 check_returncode : bool | None = None ,
17931790 ** kwargs : t .Any ,
17941791 ) -> Version :
17951792 """Get git version. Wraps `git version <https://git-scm.com/docs/git-version>`_.
17961793
1797- Parameters
1798- ----------
1799- build_options : bool, optional
1800- Include build options in the output with ``--build-options``
1801-
18021794 Returns
18031795 -------
18041796 Version
@@ -1816,16 +1808,9 @@ def version(
18161808 >>> version = git.version()
18171809 >>> isinstance(version.major, int)
18181810 True
1819-
1820- >>> version = git.version(build_options=True)
1821- >>> isinstance(version.major, int)
1822- True
18231811 """
18241812 local_flags : list [str ] = []
18251813
1826- if build_options is True :
1827- local_flags .append ("--build-options" )
1828-
18291814 output = self .run (
18301815 ["version" , * local_flags ],
18311816 check_returncode = check_returncode ,
@@ -1837,7 +1822,7 @@ def version(
18371822 return parse_version (version_str )
18381823
18391824 # Raise exception if output format is unexpected
1840- raise InvalidVersion (f"Unexpected git version output format: { output } " )
1825+ raise InvalidVersion (output )
18411826
18421827 def build_options (
18431828 self ,
@@ -1880,7 +1865,7 @@ def build_options(
18801865 # First line is always "git version X.Y.Z"
18811866 lines = output .strip ().split ("\n " )
18821867 if not lines or not lines [0 ].startswith ("git version " ):
1883- raise InvalidBuildOptions (f"Unexpected git version output format: { output } " )
1868+ raise InvalidBuildOptions (output )
18841869
18851870 version_str = lines [0 ].replace ("git version " , "" ).strip ()
18861871 result .version = version_str
@@ -1916,8 +1901,10 @@ def build_options(
19161901 result .sizeof_size_t = value
19171902 elif key == "shell-path" :
19181903 result .shell_path = value
1919- # Special handling for the commit line which often has no colon
1920- elif "commit" in line and "no commit" not in line .lower ():
1904+ elif key == "commit" :
1905+ result .commit = value
1906+ # Special handling for the "no commit" line which has no colon
1907+ elif "no commit associated with this build" in line .lower ():
19211908 result .commit = line
19221909
19231910 return result
0 commit comments