public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
Date: Tue, 26 Dec 2023 17:45:12 +0000 (UTC)	[thread overview]
Message-ID: <1703612638.f9b39f8d7a18859450c6351ef77e72ef032621be.arthurzam@gentoo> (raw)

commit:     f9b39f8d7a18859450c6351ef77e72ef032621be
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 25 21:42:12 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 26 17:43:58 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=f9b39f8d

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 <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/cpv.py | 8 ++++----
 tests/ebuild/test_cpv.py  | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/pkgcore/ebuild/cpv.py b/src/pkgcore/ebuild/cpv.py
index 774051e07..b7149fc1e 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 e014d751d..1a778a936 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 = (


             reply	other threads:[~2023-12-26 17:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 17:45 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-12  7:13 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/ Arthur Zamarin
2023-08-28 17:49 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-10-08 10:09 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1703612638.f9b39f8d7a18859450c6351ef77e72ef032621be.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox