commit:     2398378d4da3c70d7b9c16cd32491d2a0a8fd674
Author:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 16 18:37:40 2025 +0000
Commit:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
CommitDate: Sun Nov 16 18:41:30 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2398378d

dev-vcs/git-filter-repo: Fix python3.14 and re-add support

Closes: https://github.com/gentoo/gentoo/pull/44475
See https://github.com/gentoo/gentoo/pull/44450#issuecomment-3487926349

Signed-off-by: Sasha Finkelstein <fnkl.kernel <AT> gmail.com>
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>

 ...git-filter-repo-2.47.0-python3.14-lower-z.patch | 64 ++++++++++++++++++++++
 .../git-filter-repo-2.47.0-r1.ebuild               | 54 ++++++++++++++++++
 2 files changed, 118 insertions(+)

diff --git 
a/dev-vcs/git-filter-repo/files/git-filter-repo-2.47.0-python3.14-lower-z.patch 
b/dev-vcs/git-filter-repo/files/git-filter-repo-2.47.0-python3.14-lower-z.patch
new file mode 100644
index 000000000000..89b464fdb480
--- /dev/null
+++ 
b/dev-vcs/git-filter-repo/files/git-filter-repo-2.47.0-python3.14-lower-z.patch
@@ -0,0 +1,64 @@
+From c1d8461ee34c6d3f987e0f19191f2105cb2a33c8 Mon Sep 17 00:00:00 2001
+From: Elijah Newren <[email protected]>
+Date: Fri, 25 Jul 2025 21:24:54 -0700
+Subject: [PATCH] filter-repo: fix --replace-text for python3.14
+
+Our handling of globs for --replace-text makes use of fnmatch.translate
+from the python standard library.  Unfortunately, fnmatch.translate
+doesn't just give a regex that can match the given glob somewhere, it
+gives a regex that will only match if the string it is comparing to is
+exactly that glob.  We need a substring search, though, so we have to
+use an ugly hack to butcher the returned regex from fnmatch to get it
+to be what we want.  (It would be nice if python's fnmatch.translate()
+took options for what was wanted, but it doesn't.)  This is fine, except
+that...
+
+python3.14 added '\z' as a synonym for '\Z' in regexes.  No special
+reason, they just wanted there to be more than one way to do it.
+
+Naturally, fnmatch.translate() uses '\z' instead of '\Z', so our regex
+hackery in glob_to_regex() wasn't looking for the right stuff to hack
+off, causing the globs to fail to match text as expected.
+
+Add a python >= 3.14 hack to the existing python variation hacks in
+glob_to_regex() so we can handle this case too.
+
+While at it, the --replace-text test in t9394 did replacements on a
+literal, a glob, and a regex, but it only verified that the glob and
+regex replacements worked.  Supplement it with a check that the
+literal replacement worked too.
+
+Signed-off-by: Elijah Newren <[email protected]>
+---
+ git-filter-repo                                            | 3 +++
+ t/t9394-filter-repo-sanity-checks-and-bigger-repo-setup.sh | 3 +++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/git-filter-repo b/git-filter-repo
+index 39c8680a..fb3de42e 100755
+--- a/git-filter-repo
++++ b/git-filter-repo
+@@ -154,6 +154,9 @@ def glob_to_regex(glob_bytestr):
+     regex = regex[0:-7]
+   elif regex.startswith(r'(?s:') and regex.endswith(r')\Z'): # pragma: no 
cover
+     regex = regex[4:-3]
++  elif regex.startswith(r'(?s:') and regex.endswith(r')\z'): # pragma: no 
cover
++    # Yaay, python3.14 for senselessly duplicating \Z as \z...
++    regex = regex[4:-3]
+ 
+   # Finally, convert back to regex operating on bytestr
+   return regex.encode()
+diff --git a/t/t9394-filter-repo-sanity-checks-and-bigger-repo-setup.sh 
b/t/t9394-filter-repo-sanity-checks-and-bigger-repo-setup.sh
+index 0ff911db..5358cd5a 100755
+--- a/t/t9394-filter-repo-sanity-checks-and-bigger-repo-setup.sh
++++ b/t/t9394-filter-repo-sanity-checks-and-bigger-repo-setup.sh
+@@ -654,6 +654,9 @@ test_expect_success '--replace-text all options' '
+               git show HEAD~4:numbers/medium.num >actual &&
+               test_cmp expect actual &&
+ 
++              echo "foodstuff" >expect &&
++              test_cmp expect sequence/to &&
++
+               echo "haphazard ***REMOVED*** variation" >expect &&
+               test_cmp expect whatever
+       )

diff --git a/dev-vcs/git-filter-repo/git-filter-repo-2.47.0-r1.ebuild 
b/dev-vcs/git-filter-repo/git-filter-repo-2.47.0-r1.ebuild
new file mode 100644
index 000000000000..e04cc2e249ab
--- /dev/null
+++ b/dev-vcs/git-filter-repo/git-filter-repo-2.47.0-r1.ebuild
@@ -0,0 +1,54 @@
+# Copyright 2021-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..14} )
+
+inherit distutils-r1
+
+DESCRIPTION="Quickly rewrite git repository history (filter-branch 
replacement)"
+HOMEPAGE="https://github.com/newren/git-filter-repo/";
+SRC_URI="https://github.com/newren/git-filter-repo/releases/download/v${PV}/${P}.tar.xz";
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="amd64 ~arm64 ~loong ~x86"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="
+       dev-vcs/git
+"
+BDEPEND="
+       dev-python/setuptools-scm[${PYTHON_USEDEP}]
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-2.47.0-python3.14-lower-z.patch"
+)
+
+# the git-archive tarball does not have version info; setuptools-scm
+# requires a valid source of version info, this one is for distros
+export SETUPTOOLS_SCM_PRETEND_VERSION=${PV}
+
+python_test() {
+       cd .. || die
+       bash "${S}"/t/run_tests || die
+}
+
+python_install_all() {
+       distutils-r1_python_install_all
+
+       # Just like git itself there is a manpage in troff + html formats.
+       # Unlike git itself, we cannot install the html one, because the
+       # `git --html-path` has the ${PV} of git in it. So just install
+       # the troff copy.
+       doman "${WORKDIR}"/${P}/Documentation/man1/git-filter-repo.1
+
+       # Points to dead symlink
+       rm "${ED}"/usr/share/doc/${PF}/README.md || die
+       rmdir "${ED}"/usr/share/doc/${PF} || die
+
+       dodoc "${WORKDIR}"/${P}/README.md
+}

Reply via email to