Skip to content

Commit ee987da

Browse files
authored
Merge pull request #1918 from kamilkrzyskow/patch-1
Fix iter_change_type diff renamed property to prevent warning
2 parents ca1d031 + e1c660d commit ee987da

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

git/diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def iter_change_type(self, change_type: Lit_change_type) -> Iterator[T_Diff]:
325325
yield diffidx
326326
elif change_type == "C" and diffidx.copied_file:
327327
yield diffidx
328-
elif change_type == "R" and diffidx.renamed:
328+
elif change_type == "R" and diffidx.renamed_file:
329329
yield diffidx
330330
elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob:
331331
yield diffidx

test/deprecation/test_basic.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
if TYPE_CHECKING:
3232
from pathlib import Path
3333

34-
from git.diff import Diff
34+
from git.diff import Diff, DiffIndex
3535
from git.objects.commit import Commit
3636

3737
# ------------------------------------------------------------------------
@@ -54,6 +54,12 @@ def diff(commit: "Commit") -> Generator["Diff", None, None]:
5454
yield diff
5555

5656

57+
@pytest.fixture
58+
def diffs(commit: "Commit") -> Generator["DiffIndex", None, None]:
59+
"""Fixture to supply a DiffIndex."""
60+
yield commit.diff(NULL_TREE)
61+
62+
5763
def test_diff_renamed_warns(diff: "Diff") -> None:
5864
"""The deprecated Diff.renamed property issues a deprecation warning."""
5965
with pytest.deprecated_call():
@@ -122,3 +128,10 @@ def test_iterable_obj_inheriting_does_not_warn() -> None:
122128

123129
class Derived(IterableObj):
124130
pass
131+
132+
133+
def test_diff_iter_change_type(diffs: "DiffIndex") -> None:
134+
"""The internal DiffIndex.iter_change_type function issues no deprecation warning."""
135+
with assert_no_deprecation_warning():
136+
for change_type in diffs.change_type:
137+
[*diffs.iter_change_type(change_type=change_type)]

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