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
yielddiffidx
326326
elifchange_type=="C"anddiffidx.copied_file:
327327
yielddiffidx
328-
elifchange_type=="R"anddiffidx.renamed:
328+
elifchange_type=="R"anddiffidx.renamed_file:
329329
yielddiffidx
330330
elifchange_type=="M"anddiffidx.a_blobanddiffidx.b_blobanddiffidx.a_blob!=diffidx.b_blob:
331331
yielddiffidx

‎test/deprecation/test_basic.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
ifTYPE_CHECKING:
3232
frompathlibimportPath
3333

34-
fromgit.diffimportDiff
34+
fromgit.diffimportDiff, DiffIndex
3535
fromgit.objects.commitimportCommit
3636

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

5656

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

123129
classDerived(IterableObj):
124130
pass
131+
132+
133+
deftest_diff_iter_change_type(diffs: "DiffIndex") ->None:
134+
"""The internal DiffIndex.iter_change_type function issues no deprecation warning."""
135+
withassert_no_deprecation_warning():
136+
forchange_typeindiffs.change_type:
137+
[*diffs.iter_change_type(change_type=change_type)]

0 commit comments

Comments
(0)