← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:conda-leading-underscore into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:conda-leading-underscore into launchpad:master.

Commit message:
Allow leading underscores in Conda package names

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/425404

As previously mentioned, there doesn't seem to be a clear specification of this, but I've seen leading underscores in the wild and there's little harm in allowing them.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:conda-leading-underscore into launchpad:master.
diff --git a/lib/lp/soyuz/model/binarypackagerelease.py b/lib/lp/soyuz/model/binarypackagerelease.py
index d363f07..f697c97 100644
--- a/lib/lp/soyuz/model/binarypackagerelease.py
+++ b/lib/lp/soyuz/model/binarypackagerelease.py
@@ -67,7 +67,7 @@ wheel_name_pattern = re.compile(
 # checks, but apparently in terms of which characters are forbidden rather
 # than which characters are allowed.  For now, constrain this to something
 # reasonably conservative and hope that this is OK.
-conda_name_pattern = re.compile(r"^[a-z0-9][a-z0-9.+_-]*$")
+conda_name_pattern = re.compile(r"^[a-z0-9_][a-z0-9.+_-]*$")
 
 
 def _validate_bpr_name(obj: IBinaryPackageRelease, attr: str, value: Any):
diff --git a/lib/lp/soyuz/tests/test_binarypackagerelease.py b/lib/lp/soyuz/tests/test_binarypackagerelease.py
index 9826000..5adbdb2 100644
--- a/lib/lp/soyuz/tests/test_binarypackagerelease.py
+++ b/lib/lp/soyuz/tests/test_binarypackagerelease.py
@@ -3,8 +3,6 @@
 
 """Test BinaryPackageRelease."""
 
-from psycopg2.errors import CheckViolation
-
 from lp.soyuz.enums import BinaryPackageFormat
 from lp.soyuz.interfaces.binarypackagerelease import (
     BinaryPackageReleaseNameLinkageError,
@@ -69,75 +67,61 @@ class TestBinaryPackageRelease(TestCaseWithFactory):
 
     def test_deb_name(self):
         self.factory.makeBinaryPackageRelease(binarypackagename="foo")
-        try:
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="foo_bar")
-        except CheckViolation:
-            # Temporarily allow this until the BinaryPackageName.name DB
-            # constraint is relaxed.
-            pass
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="foo_bar")
 
     def test_wheel_name(self):
         self.factory.makeBinaryPackageRelease(
             binarypackagename="foo", binpackageformat=BinaryPackageFormat.WHL)
-        try:
-            self.factory.makeBinaryPackageRelease(
-                binarypackagename="Foo_bar",
-                binpackageformat=BinaryPackageFormat.WHL)
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="foo_bar+",
-                binpackageformat=BinaryPackageFormat.WHL)
-        except CheckViolation:
-            # Temporarily allow this until the BinaryPackageName.name DB
-            # constraint is relaxed.
-            pass
+        self.factory.makeBinaryPackageRelease(
+            binarypackagename="Foo_bar",
+            binpackageformat=BinaryPackageFormat.WHL)
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="foo_bar+",
+            binpackageformat=BinaryPackageFormat.WHL)
 
     def test_conda_v1_name(self):
         self.factory.makeBinaryPackageRelease(
             binarypackagename="foo",
             binpackageformat=BinaryPackageFormat.CONDA_V1)
-        try:
-            self.factory.makeBinaryPackageRelease(
-                binarypackagename="foo-bar_baz",
-                binpackageformat=BinaryPackageFormat.CONDA_V1)
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="Foo",
-                binpackageformat=BinaryPackageFormat.CONDA_V1)
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="foo_bar#",
-                binpackageformat=BinaryPackageFormat.CONDA_V1)
-        except CheckViolation:
-            # Temporarily allow this until the BinaryPackageName.name DB
-            # constraint is relaxed.
-            pass
+        self.factory.makeBinaryPackageRelease(
+            binarypackagename="foo-bar_baz",
+            binpackageformat=BinaryPackageFormat.CONDA_V1)
+        self.factory.makeBinaryPackageRelease(
+            binarypackagename="_foo",
+            binpackageformat=BinaryPackageFormat.CONDA_V1)
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="Foo",
+            binpackageformat=BinaryPackageFormat.CONDA_V1)
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="foo_bar#",
+            binpackageformat=BinaryPackageFormat.CONDA_V1)
 
     def test_conda_v2_name(self):
         self.factory.makeBinaryPackageRelease(
             binarypackagename="foo",
             binpackageformat=BinaryPackageFormat.CONDA_V2)
-        try:
-            self.factory.makeBinaryPackageRelease(
-                binarypackagename="foo-bar_baz",
-                binpackageformat=BinaryPackageFormat.CONDA_V2)
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="Foo",
-                binpackageformat=BinaryPackageFormat.CONDA_V2)
-            self.assertRaises(
-                BinaryPackageReleaseNameLinkageError,
-                self.factory.makeBinaryPackageRelease,
-                binarypackagename="foo_bar#",
-                binpackageformat=BinaryPackageFormat.CONDA_V2)
-        except CheckViolation:
-            # Temporarily allow this until the BinaryPackageName.name DB
-            # constraint is relaxed.
-            pass
+        self.factory.makeBinaryPackageRelease(
+            binarypackagename="foo-bar_baz",
+            binpackageformat=BinaryPackageFormat.CONDA_V2)
+        self.factory.makeBinaryPackageRelease(
+            binarypackagename="_foo",
+            binpackageformat=BinaryPackageFormat.CONDA_V2)
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="Foo",
+            binpackageformat=BinaryPackageFormat.CONDA_V2)
+        self.assertRaises(
+            BinaryPackageReleaseNameLinkageError,
+            self.factory.makeBinaryPackageRelease,
+            binarypackagename="foo_bar#",
+            binpackageformat=BinaryPackageFormat.CONDA_V2)