Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb438ee

Browse files
committed
Refactor and further clarify comments
+ Put assertion only on the branch where mypy benefits from it.
1 parent82b0a1e commiteb438ee

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

‎git/cmd.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -833,28 +833,29 @@ def working_dir(self) -> Union[None, PathLike]:
833833
@property
834834
defversion_info(self)->Tuple[int,int,int,int]:
835835
"""
836-
:return: tuple(int, int, int, int) tuple with integers representing the major, minor
837-
and additional version numbers as parsed from git version.
836+
:return: tuple(int, int, int, int) tuple with integers representing the major,
837+
minorand additional version numbers as parsed from git version.
838838
839839
This value is generated on demand and is cached.
840840
"""
841-
# Use a copy of this global state, in case of a concurrent refresh.
842-
refresh_token=self._refresh_token
843-
844-
# Ask git for its version if we haven't done so since the last refresh.
845-
# (Refreshing is global, but version_info caching is per-instance.)
846-
ifself._version_info_tokenisnotrefresh_token:
847-
# We only use the first 4 numbers, as everything else could be strings in fact (on Windows).
848-
process_version=self._call_process("version")# Should be as default *args and **kwargs used.
849-
version_numbers=process_version.split(" ")[2]
850-
851-
self._version_info=cast(
852-
Tuple[int,int,int,int],
853-
tuple(int(n)forninversion_numbers.split(".")[:4]ifn.isdigit()),
854-
)
855-
self._version_info_token=refresh_token
841+
# Refreshing is global, but version_info caching is per-instance.
842+
refresh_token=self._refresh_token# Copy token in case of concurrent refresh.
843+
844+
# Use the cached version if obtained after the most recent refresh.
845+
ifself._version_info_tokenisrefresh_token:
846+
assertself._version_infoisnotNone,"Bug: corrupted token-check state"
847+
returnself._version_info
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]
852+
853+
self._version_info=cast(
854+
Tuple[int,int,int,int],
855+
tuple(int(n)forninversion_numbers.split(".")[:4]ifn.isdigit()),
856+
)
857+
self._version_info_token=refresh_token
856858

857-
assertself._version_infoisnotNone,"Bug: token check should never let None through"
858859
returnself._version_info
859860

860861
@overload

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp