mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2025-12-09 00:07:57 +03:00
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@gmail.com> Signed-off-by: Mike Pagano <mpagano@gentoo.org>
This commit is contained in:
parent
45732dbd7b
commit
2398378d4d
@ -0,0 +1,64 @@
|
||||
From c1d8461ee34c6d3f987e0f19191f2105cb2a33c8 Mon Sep 17 00:00:00 2001
|
||||
From: Elijah Newren <newren@gmail.com>
|
||||
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 <newren@gmail.com>
|
||||
---
|
||||
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
|
||||
)
|
||||
54
dev-vcs/git-filter-repo/git-filter-repo-2.47.0-r1.ebuild
Normal file
54
dev-vcs/git-filter-repo/git-filter-repo-2.47.0-r1.ebuild
Normal file
@ -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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user