From d59708812f50362f526d4c6aa67b7218d12024f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Krzy=C5=9Bk=C3=B3w?= Date: Sat, 8 Jun 2024 01:23:21 +0200 Subject: [PATCH 1/2] Add deprecation test for DiffIndex.iter_change_type --- test/deprecation/test_basic.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/deprecation/test_basic.py b/test/deprecation/test_basic.py index 6235a836c..3bf0287c7 100644 --- a/test/deprecation/test_basic.py +++ b/test/deprecation/test_basic.py @@ -31,7 +31,7 @@ if TYPE_CHECKING: from pathlib import Path - from git.diff import Diff + from git.diff import Diff, DiffIndex from git.objects.commit import Commit # ------------------------------------------------------------------------ @@ -54,6 +54,12 @@ def diff(commit: "Commit") -> Generator["Diff", None, None]: yield diff +@pytest.fixture +def diffs(commit: "Commit") -> Generator["DiffIndex", None, None]: + """Fixture to supply a DiffIndex.""" + yield commit.diff(NULL_TREE) + + def test_diff_renamed_warns(diff: "Diff") -> None: """The deprecated Diff.renamed property issues a deprecation warning.""" with pytest.deprecated_call(): @@ -122,3 +128,10 @@ def test_iterable_obj_inheriting_does_not_warn() -> None: class Derived(IterableObj): pass + + +def test_diff_iter_change_type(diffs: "DiffIndex") -> None: + """The internal DiffIndex.iter_change_type function issues no deprecation warning.""" + with assert_no_deprecation_warning(): + for change_type in diffs.change_type: + [*diffs.iter_change_type(change_type=change_type)] From e1c660d224a1d27469c9275940c9db841570b8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Krzy=C5=9Bk=C3=B3w?= <34622465+kamilkrzyskow@users.noreply.github.com> Date: Tue, 28 May 2024 05:53:44 +0200 Subject: [PATCH 2/2] Fix iter_change_type diff renamed property to prevent warning --- git/diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/diff.py b/git/diff.py index e9f7e209f..8d2646f99 100644 --- a/git/diff.py +++ b/git/diff.py @@ -325,7 +325,7 @@ def iter_change_type(self, change_type: Lit_change_type) -> Iterator[T_Diff]: yield diffidx elif change_type == "C" and diffidx.copied_file: yield diffidx - elif change_type == "R" and diffidx.renamed: + elif change_type == "R" and diffidx.renamed_file: yield diffidx elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob: yield diffidx 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