Skip to content

Commit 06a40ba

Browse files
committed
review
1 parent 1be793c commit 06a40ba

3 files changed

Lines changed: 24 additions & 27 deletions

File tree

‎doc/source/changes.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ API changes
170170
Missing paths within a valid tree revision raise ``Tree.join()``'s ``KeyError``
171171
with its missing-component message.
172172

173+
* ``FetchInfo.refresh()`` is deprecated and no longer needed. Git has used
174+
``t`` for fetch tag updates since 2.10, and GitPython requires Git 2.52 or
175+
newer. Remove calls to this method; ``git.refresh()`` still configures the
176+
Git executable.
173177
* ``IndexFile.entries`` returns an immutable snapshot keyed by ``(path, stage)``
174178
for compatibility with existing readers. Each access queries the current
175179
on-disk or pending index; previously returned snapshots retain their values.

‎git/__init__.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ def refresh(path: Optional[PathLike] = None) -> None:
195195
:meth:`Git.refresh <git.cmd.Git.refresh>` for details on how to achieve this.
196196
197197
:note:
198-
This calls :meth:`Git.refresh <git.cmd.Git.refresh>` and sets other global
199-
configuration according to the effect of doing so. As such, this function should
200-
usually be used instead of using :meth:`Git.refresh <git.cmd.Git.refresh>` or
201-
:meth:`FetchInfo.refresh <git.remote.FetchInfo.refresh>` directly.
198+
This calls :meth:`Git.refresh <git.cmd.Git.refresh>` and updates ``GIT_OK``.
199+
Prefer this function to calling :meth:`Git.refresh <git.cmd.Git.refresh>` directly.
202200
203201
:note:
204202
This function is called automatically, with no arguments, at import time.
@@ -208,8 +206,6 @@ def refresh(path: Optional[PathLike] = None) -> None:
208206

209207
if not Git.refresh(path=path):
210208
return
211-
if not FetchInfo.refresh(): # noqa: F405
212-
return # type: ignore[unreachable]
213209

214210
GIT_OK = True
215211

‎git/remote.py‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,11 @@
99

1010
import logging
1111
import re
12-
13-
from git.cmd import Git, handle_process_output
14-
from git.compat import force_text
15-
from git.config import GitConfigParser, SectionConstraint, cp
16-
from git.refs import Reference, RemoteReference, SymbolicReference, TagReference
17-
from git.util import (
18-
CallableRemoteProgress,
19-
IterableList,
20-
IterableObj,
21-
LazyMixin,
22-
RemoteProgress,
23-
)
12+
import warnings
2413

2514
# typing-------------------------------------------------------
26-
2715
from typing import (
16+
TYPE_CHECKING,
2817
Any,
2918
Callable,
3019
Dict,
@@ -33,14 +22,24 @@
3322
NoReturn,
3423
Optional,
3524
Sequence,
36-
TYPE_CHECKING,
3725
TypeVar,
3826
Union,
3927
cast,
4028
overload,
4129
)
4230

31+
from git.cmd import Git, handle_process_output
32+
from git.compat import force_text
33+
from git.config import GitConfigParser, SectionConstraint, cp
34+
from git.refs import Reference, RemoteReference, SymbolicReference, TagReference
4335
from git.types import AnyGitObject, Literal, PathLike
36+
from git.util import (
37+
CallableRemoteProgress,
38+
IterableList,
39+
IterableObj,
40+
LazyMixin,
41+
RemoteProgress,
42+
)
4443

4544
if TYPE_CHECKING:
4645
from git.objects.commit import Commit
@@ -323,19 +322,17 @@ class FetchInfo(IterableObj):
323322
"*": 0,
324323
"=": HEAD_UPTODATE,
325324
" ": FAST_FORWARD,
326-
"-": TAG_UPDATE,
325+
"t": TAG_UPDATE,
327326
}
328327

329328
@classmethod
330329
def refresh(cls) -> Literal[True]:
331-
"""Update information about which :manpage:`git-fetch(1)` flags are supported
332-
by the git executable being used.
330+
"""Deprecated and no longer needed.
333331
334-
Called by the :func:`git.refresh` function in the top level ``__init__``.
332+
Git has used ``t`` for fetch tag updates since Git 2.10. GitPython
333+
requires Git 2.52 or newer, so no version-specific mapping is needed.
335334
"""
336-
cls._flag_map["t"] = cls.TAG_UPDATE
337-
cls._flag_map["-"] = 0
338-
335+
warnings.warn("FetchInfo.refresh() is deprecated and no longer needed", DeprecationWarning, stacklevel=2)
339336
return True
340337

341338
def __init__(

0 commit comments

Comments
 (0)