Skip to content

Commit 629fd87

Browse files
committed
Fix how version_info omits non-numeric fields
For #1833. This makes version_info parsing stop including fields after the first non-numeric field, rather than skipping non-numeric fields and including subsequent numeric fields that then wrongly appear to have the original position and significance of the dropped field. This actually stops at (rather than merely after) a non-numeric field, i.e., potentially parseable fields that are not fully numeric, such as "2a", are stopped at, rather than parsed as "2".
1 parent ac20325 commit 629fd87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

git/cmd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import contextlib
1010
import io
11+
import itertools
1112
import logging
1213
import os
1314
import signal
@@ -850,7 +851,8 @@ def version_info(self) -> Tuple[int, ...]:
850851
process_version = self._call_process("version")
851852
version_string = process_version.split(" ")[2]
852853
version_fields = version_string.split(".")[:4]
853-
self._version_info = tuple(int(n) for n in version_fields if n.isdigit())
854+
leading_numeric_fields = itertools.takewhile(str.isdigit, version_fields)
855+
self._version_info = tuple(map(int, leading_numeric_fields))
854856

855857
# This value will be considered valid until the next refresh.
856858
self._version_info_token = refresh_token

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy