From 6b43121c139e47641efe32f68333aae7909b9162 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 1 Sep 2022 21:01:54 +0100 Subject: Correctly linkify packages with a version-constraint --- calm/pkg2html.py | 6 ++++-- test/testdata/htdocs.expected/summary/test-c.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/calm/pkg2html.py b/calm/pkg2html.py index f6a2ada..4924847 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -147,10 +147,12 @@ def update_package_listings(args, packages): toremove = glob.glob(os.path.join(summaries, '*')) - def linkify_package(p): + def linkify_package(pkg): + p = re.sub(r'(.*)\s+\(.*\)', r'\1', pkg) if p in package_list: pn = arch_package(packages, p).orig_name - return '%s' % (p, pn) + text = re.sub(re.escape(p), pn, pkg) + return '%s' % (p, text) logging.debug('package linkification failed for %s' % p) return p diff --git a/test/testdata/htdocs.expected/summary/test-c.html b/test/testdata/htdocs.expected/summary/test-c.html index 2a0d186..200bd7b 100644 --- a/test/testdata/htdocs.expected/summary/test-c.html +++ b/test/testdata/htdocs.expected/summary/test-c.html @@ -13,7 +13,7 @@ summary: test package C

description: test package C

categories: Devel

-depends: test-d (>= 1.0), test-e

+depends: test-d (>= 1.0), test-e

obsoletes: obs-a, obs-b

source package: test-c

maintainer(s): ORPHANED -- cgit v1.2.3