Skip to content

Commit f9116e8

Browse files
committed
fix: update categories rules to match PMS
Bug pkgcore#453. That code's pre spec existance, and back when I was trying to sell people on N>1 depth categories. PMS allows some weird stuff, but add explicit tests for this. Signed-off-by: Brian Harring <[email protected]>
1 parent 777c7f3 commit f9116e8

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/pkgcore/ebuild/cpv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
r"^(?:\d+)(?:\.\d+)*[a-zA-Z]?(?:_(p(?:re)?|beta|alpha|rc)\d*)*$",
2222
)
2323

24-
demand_compile_regexp(
25-
"isvalid_cat_re", r"^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$"
26-
)
24+
# see https://github.com/pkgcore/pkgcore/issues/453 for why this regex underscores
25+
# PMS Category names regex is directly replicated below.#
26+
demand_compile_regexp("isvalid_cat_re", r"^(?:[A-Za-z0-9_][A-Za-z0-9+_-]*)$")
2727

2828
# empty string is fine, means a -- was encounter.
2929
demand_compile_regexp("_pkg_re", r"^[a-zA-Z0-9+_]+$")

tests/ebuild/test_cpv.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from random import shuffle
22

33
import pytest
4+
45
from pkgcore.ebuild import cpv
56

67

@@ -20,19 +21,25 @@ def generate_misc_sufs():
2021

2122
class TestCPV:
2223
good_cats = (
24+
# see https://github.com/pkgcore/pkgcore/issues/453 . PMS regex broke from pre spec allowing some weird stuff.
2325
"dev-util",
2426
"dev+",
25-
"dev-util+",
26-
"DEV-UTIL",
27+
"DEV-UTIL+",
2728
"aaa0",
2829
"aaa-0",
29-
"multi/depth",
30-
"cross-dev_idiot.hacks-suck",
31-
"a",
32-
"foo---",
3330
"multi--hyphen",
31+
"_dev",
32+
"_", # yep, that's legal.
33+
)
34+
bad_cats = (
35+
"",
36+
"-",
37+
"+",
38+
"dev-util ",
39+
"multi/blah/depth",
40+
"multi//depth",
41+
"reject.a",
3442
)
35-
bad_cats = (".util", "_dev", "", "dev-util ", "multi//depth")
3643
good_pkgs = (
3744
"diffball",
3845
"a9",

0 commit comments

Comments
 (0)