aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-12-25 13:42:12 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-12-26 19:43:58 +0200
commitf9b39f8d7a18859450c6351ef77e72ef032621be (patch)
tree69b1f8d540d0e310c6c778f59eb64a6fa7573018
parentstart work on 0.12.25 (diff)
downloadpkgcore-f9b39f8d7a18859450c6351ef77e72ef032621be.tar.gz
pkgcore-f9b39f8d7a18859450c6351ef77e72ef032621be.tar.bz2
pkgcore-f9b39f8d7a18859450c6351ef77e72ef032621be.zip
Fix: parsing bug that allows a revision to be part of a package
The previous logic was just checking for a trailing version component; it wasn't checking for a trailing revision. Relates to issue: #419 Signed-off-by: Brian Harring <ferringb@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgcore/ebuild/cpv.py8
-rw-r--r--tests/ebuild/test_cpv.py1
2 files changed, 5 insertions, 4 deletions
diff --git a/src/pkgcore/ebuild/cpv.py b/src/pkgcore/ebuild/cpv.py
index 774051e0..b7149fc1 100644
--- a/src/pkgcore/ebuild/cpv.py
+++ b/src/pkgcore/ebuild/cpv.py
@@ -38,11 +38,11 @@ def isvalid_pkg_name(chunks):
if not all(not s or _pkg_re.match(s) for s in chunks):
return False
# the package name must not end with a hyphen followed by anything that
- # looks like a version -- need to ensure that we've gotten more than one
+ # looks like a version or revision -- need to ensure that we've gotten more than one
# chunk, i.e. at least one hyphen
- if len(chunks) > 1 and isvalid_version_re.match(chunks[-1]):
- return False
- return True
+ if len(chunks) == 1:
+ return True
+ return not (isvalid_version_re.match(chunks[-1]) or isvalid_rev(chunks[-1]))
def isvalid_rev(s: str):
diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index e014d751..1a778a93 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -52,6 +52,7 @@ class TestCPV:
"+dfa",
"timidity--9f",
"ormaybe---13_beta",
+ "bar-11-r3",
)
good_cp = (