summaryrefslogtreecommitdiffstats
path: root/third_party/python/mozilla_repo_urls
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/python/mozilla_repo_urls
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/mozilla_repo_urls')
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/METADATA16
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/RECORD12
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/WHEEL5
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/top_level.txt2
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/__init__.py2
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/errors.py15
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py27
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/__init__.py5
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/hgmo.py55
-rw-r--r--third_party/python/mozilla_repo_urls/mozilla_repo_urls/result.py35
-rw-r--r--third_party/python/mozilla_repo_urls/test/__init__.py6
-rw-r--r--third_party/python/mozilla_repo_urls/test/test_integration.py493
12 files changed, 673 insertions, 0 deletions
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/METADATA b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/METADATA
new file mode 100644
index 0000000000..a74753553c
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/METADATA
@@ -0,0 +1,16 @@
+Metadata-Version: 2.1
+Name: mozilla-repo-urls
+Version: 0.1.0
+Summary: Process Mozilla's repository URLs. The intent is to centralize URLs parsing.
+Home-page: https://github.com/mozilla-releng/mozilla-repo-urls
+Author: Mozilla Release Engineering
+Author-email: release+python@mozilla.com
+License: MPL2
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
+Requires-Dist: giturlparse
+
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/RECORD b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/RECORD
new file mode 100644
index 0000000000..c62f0ef740
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/RECORD
@@ -0,0 +1,12 @@
+mozilla_repo_urls/__init__.py,sha256=seFB5ueyozmIXZxBWVATYPbQCzNln2SWSTirc0yk_A0,108
+mozilla_repo_urls/errors.py,sha256=koXTtW_axWwCtWVHkvxXjYqAq1AXYbN54Q-C8veqDNw,485
+mozilla_repo_urls/parser.py,sha256=a6Q1x8o_yu4Qof86aq2M8dwPhiMeAzCV7LxAw7CzwRg,805
+mozilla_repo_urls/result.py,sha256=sJEJDdfML72MR3oZtVdMRo18FbPl8SP9-pQUyF4RQBE,952
+mozilla_repo_urls/platforms/__init__.py,sha256=5gwGbeTZUI-0VR0HmC3913e6AUTylDkjmcXYkg8QwYc,89
+mozilla_repo_urls/platforms/hgmo.py,sha256=8vzw9GUaBylHEY1qWGvdIbkzYdUHeVoYYkwUQOjJktE,1893
+test/__init__.py,sha256=ui4glNH_cCoz4Ex7hcZhHTcstOPJb2wcojFiNvvIALI,88
+test/test_integration.py,sha256=KcRIoMywtngzpIrqAHn7hMYiDZR_v7kQeJX68ZFG9JM,19412
+mozilla_repo_urls-0.1.0.dist-info/METADATA,sha256=oRTxklWzIh89m-BV6WFPKH3ww7dKJm9ltWxhe8Ipd7s,628
+mozilla_repo_urls-0.1.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
+mozilla_repo_urls-0.1.0.dist-info/top_level.txt,sha256=0LuRstNeetmfWdKTPvknIx8aDVzsf1KSmASCgOvKvDM,23
+mozilla_repo_urls-0.1.0.dist-info/RECORD,,
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/WHEEL b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/WHEEL
new file mode 100644
index 0000000000..becc9a66ea
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/WHEEL
@@ -0,0 +1,5 @@
+Wheel-Version: 1.0
+Generator: bdist_wheel (0.37.1)
+Root-Is-Purelib: true
+Tag: py3-none-any
+
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/top_level.txt b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/top_level.txt
new file mode 100644
index 0000000000..f70acba909
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls-0.1.0.dist-info/top_level.txt
@@ -0,0 +1,2 @@
+mozilla_repo_urls
+test
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/__init__.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/__init__.py
new file mode 100644
index 0000000000..9daa2a961a
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/__init__.py
@@ -0,0 +1,2 @@
+from mozilla_repo_urls.errors import * # noqa F401
+from mozilla_repo_urls.parser import parse # noqa F401
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/errors.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/errors.py
new file mode 100644
index 0000000000..ce3bfdb381
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/errors.py
@@ -0,0 +1,15 @@
+class RepoUrlsBaseError(Exception):
+ pass
+
+
+class InvalidRepoUrlError(RepoUrlsBaseError):
+ def __init__(self, url_string) -> None:
+ super().__init__(f"Could not parse URL: {url_string}")
+
+
+class UnsupportedPlatformError(RepoUrlsBaseError):
+ def __init__(self, url_string, platform, supported_platforms) -> None:
+ super().__init__(
+ f"Unsupported platform. Got: {platform}. "
+ f"Expected: {supported_platforms}. URL: {url_string}"
+ )
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
new file mode 100644
index 0000000000..45e79a1dbf
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/parser.py
@@ -0,0 +1,27 @@
+import giturlparse
+
+from mozilla_repo_urls.platforms import ADDITIONAL_PLATFORMS
+
+from .errors import InvalidRepoUrlError, UnsupportedPlatformError
+from .result import RepoUrlParsed
+
+for i, platform in enumerate(ADDITIONAL_PLATFORMS):
+ giturlparse.platforms.PLATFORMS.insert(i, platform)
+
+
+_SUPPORTED_PLAFORMS = ("hgmo", "github")
+
+
+def parse(url_string):
+ # Workaround for https://github.com/nephila/giturlparse/issues/43
+ url_string = url_string.rstrip("/")
+ parsed_info = giturlparse.parser.parse(url_string)
+ parsed_url = RepoUrlParsed(parsed_info)
+
+ if not parsed_url.valid:
+ raise InvalidRepoUrlError(url_string)
+
+ if parsed_url.platform not in _SUPPORTED_PLAFORMS:
+ raise UnsupportedPlatformError(url_string, platform, _SUPPORTED_PLAFORMS)
+
+ return parsed_url
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/__init__.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/__init__.py
new file mode 100644
index 0000000000..330fff5256
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/__init__.py
@@ -0,0 +1,5 @@
+from .hgmo import HgmoPlatform
+
+ADDITIONAL_PLATFORMS = [
+ ("hgmo", HgmoPlatform()),
+]
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/hgmo.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/hgmo.py
new file mode 100644
index 0000000000..539d267eca
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/platforms/hgmo.py
@@ -0,0 +1,55 @@
+from giturlparse.platforms.base import BasePlatform
+
+
+class HgmoPlatform(BasePlatform):
+ PATTERNS = {
+ "hg": (
+ r"(?P<protocols>(?P<protocol>hg))://"
+ r"(?P<domain>[^/]+?)"
+ r"(?P<transport_protocol>(|:https|:ssh))"
+ r"(?P<pathname>/"
+ r"(?P<repo>(([^/]+?)(/)?){1,2}))/?$"
+ ),
+ "https": (
+ r"(?P<protocols>(hg::)?(?P<protocol>https))://"
+ r"(?P<domain>[^/]+?)"
+ r"(?P<pathname>/"
+ r"(?P<repo>(([^/]+?)(/)?){1,2}))"
+ r"(?P<path_raw>(/raw-file/|/file/).+)?$"
+ ),
+ "ssh": (
+ r"(?P<protocols>(hg::)?(?P<protocol>ssh))(://)?"
+ r"(?P<domain>.+?)"
+ r"(?P<pathname>(:|/)"
+ r"(?P<repo>(([^/]+?)(/)?){1,2}))/?$"
+ ),
+ }
+ FORMATS = {
+ "hg": r"hg://%(domain)s:%(transport_protocol)s/%(repo)s",
+ "https": r"https://%(domain)s/%(repo)s%(path_raw)s",
+ "ssh": r"ssh://%(domain)s/%(repo)s",
+ }
+ DOMAINS = ("hg.mozilla.org",)
+ DEFAULTS = {"_user": ""}
+
+ @staticmethod
+ def clean_data(data):
+ data = BasePlatform.clean_data(data)
+ if "path_raw" in data and data["path_raw"].startswith(("/raw-file/", "/file")):
+ data["path"] = (
+ data["path_raw"].replace("/raw-file/", "").replace("/file/", "")
+ )
+
+ # git-cinnabar fixtures
+ if "transport_protocol" in data:
+ if not data["transport_protocol"]:
+ data["transport_protocol"] = "https"
+ if data["transport_protocol"].startswith(":"):
+ data["transport_protocol"] = data["transport_protocol"][1:]
+ data["protocols"][
+ 0
+ ] = f"{data['protocols'][0]}::{data['transport_protocol']}"
+ else:
+ data["transport_protocol"] = data["protocol"]
+
+ return data
diff --git a/third_party/python/mozilla_repo_urls/mozilla_repo_urls/result.py b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/result.py
new file mode 100644
index 0000000000..e420ff89e3
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/mozilla_repo_urls/result.py
@@ -0,0 +1,35 @@
+import giturlparse
+
+_DOT_GIT_SUFFIX = ".git"
+
+
+class RepoUrlParsed(giturlparse.result.GitUrlParsed):
+ @property
+ def hgmo(self) -> bool:
+ return self.platform == "hgmo"
+
+ @property
+ def git_cinnabar(self) -> bool:
+ # https://github.com/glandium/git-cinnabar
+ return len(self.protocols) > 0 and self.protocols[0].startswith("hg::")
+
+ @property
+ def repo_name(self) -> str:
+ return self.repo_path.split("/")[-1]
+
+ @property
+ def repo_path(self) -> str:
+ repo_path = (
+ self.pathname[: -len(_DOT_GIT_SUFFIX)]
+ if self.pathname.endswith(_DOT_GIT_SUFFIX)
+ else self.pathname
+ )
+ return repo_path.strip("/")
+
+ @property
+ def repo_type(self) -> str:
+ return "hg" if self.platform == "hgmo" and not self.git_cinnabar else "git"
+
+ @property
+ def taskcluster_role_prefix(self) -> str:
+ return f"repo:{self.host}/{self.repo_path}"
diff --git a/third_party/python/mozilla_repo_urls/test/__init__.py b/third_party/python/mozilla_repo_urls/test/__init__.py
new file mode 100644
index 0000000000..8010adcb1c
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/test/__init__.py
@@ -0,0 +1,6 @@
+from contextlib import contextmanager
+
+
+@contextmanager
+def does_not_raise():
+ yield
diff --git a/third_party/python/mozilla_repo_urls/test/test_integration.py b/third_party/python/mozilla_repo_urls/test/test_integration.py
new file mode 100644
index 0000000000..200c492227
--- /dev/null
+++ b/third_party/python/mozilla_repo_urls/test/test_integration.py
@@ -0,0 +1,493 @@
+from test import does_not_raise
+
+import pytest
+
+import mozilla_repo_urls
+
+
+@pytest.mark.parametrize(
+ "url_string, expectation, expected",
+ (
+ (
+ "https://hg.mozilla.org/mozilla-central",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "https://hg.mozilla.org/mozilla-central",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central",
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://hg.mozilla.org/releases/mozilla-beta",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "releases/mozilla-beta",
+ "normalized": "https://hg.mozilla.org/releases/mozilla-beta",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/releases/mozilla-beta",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "releases/mozilla-beta",
+ "repo_name": "mozilla-beta",
+ "repo_path": "releases/mozilla-beta",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-beta",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/releases/mozilla-beta",
+ "https": "https://hg.mozilla.org/releases/mozilla-beta",
+ "ssh": "ssh://hg.mozilla.org/releases/mozilla-beta",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://hg.mozilla.org/releases/mozilla-release",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "releases/mozilla-release",
+ "normalized": "https://hg.mozilla.org/releases/mozilla-release",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/releases/mozilla-release",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "releases/mozilla-release",
+ "repo_name": "mozilla-release",
+ "repo_path": "releases/mozilla-release",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-release", # noqa: E501
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/releases/mozilla-release",
+ "https": "https://hg.mozilla.org/releases/mozilla-release",
+ "ssh": "ssh://hg.mozilla.org/releases/mozilla-release",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://hg.mozilla.org/try",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "try",
+ "normalized": "https://hg.mozilla.org/try",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/try",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "try",
+ "repo_name": "try",
+ "repo_path": "try",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/try",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/try",
+ "https": "https://hg.mozilla.org/try",
+ "ssh": "ssh://hg.mozilla.org/try",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
+ "path_raw": "/raw-file/tip/taskcluster/ci/config.yml",
+ "path": "tip/taskcluster/ci/config.yml",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
+ "path_raw": "/file/tip/taskcluster/ci/config.yml",
+ "path": "tip/taskcluster/ci/config.yml",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://github.com/mozilla-mobile/fenix",
+ does_not_raise(),
+ {
+ "github": True,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": False,
+ "host": "github.com",
+ "name": "fenix",
+ "normalized": "https://github.com/mozilla-mobile/fenix.git",
+ "owner": "mozilla-mobile",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-mobile/fenix",
+ "platform": "github",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["https"],
+ "repo": "fenix",
+ "repo_name": "fenix",
+ "repo_path": "mozilla-mobile/fenix",
+ "repo_type": "git",
+ "resource": "github.com",
+ "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/fenix",
+ "urls": {
+ "git": "git://github.com/mozilla-mobile/fenix.git",
+ "https": "https://github.com/mozilla-mobile/fenix.git",
+ "ssh": "git@github.com:mozilla-mobile/fenix.git",
+ },
+ "user": "git",
+ "valid": True,
+ },
+ ),
+ (
+ "git@github.com:mozilla-mobile/firefox-android.git",
+ does_not_raise(),
+ {
+ "github": True,
+ "git_cinnabar": False,
+ "groups": [],
+ "hgmo": False,
+ "host": "github.com",
+ "name": "firefox-android",
+ "normalized": "git@github.com:mozilla-mobile/firefox-android.git",
+ "owner": "mozilla-mobile",
+ "path_raw": "",
+ "path": "",
+ "pathname": "mozilla-mobile/firefox-android.git",
+ "platform": "github",
+ "port": "",
+ "protocol": "ssh",
+ "protocols": [],
+ "repo": "firefox-android",
+ "repo_name": "firefox-android",
+ "repo_path": "mozilla-mobile/firefox-android",
+ "repo_type": "git",
+ "resource": "github.com",
+ "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/firefox-android", # noqa: E501
+ "urls": {
+ "git": "git://github.com/mozilla-mobile/firefox-android.git",
+ "https": "https://github.com/mozilla-mobile/firefox-android.git",
+ "ssh": "git@github.com:mozilla-mobile/firefox-android.git",
+ },
+ "user": "git",
+ "valid": True,
+ },
+ ),
+ (
+ "ssh://hg.mozilla.org/mozilla-unified",
+ does_not_raise(),
+ {
+ "github": False,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-unified",
+ "normalized": "ssh://hg.mozilla.org/mozilla-unified",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-unified",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "ssh",
+ "protocols": ["ssh"],
+ "repo": "mozilla-unified",
+ "repo_name": "mozilla-unified",
+ "repo_path": "mozilla-unified",
+ "repo_type": "hg",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:ssh/mozilla-unified",
+ "https": "https://hg.mozilla.org/mozilla-unified",
+ "ssh": "ssh://hg.mozilla.org/mozilla-unified",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "hg::https://hg.mozilla.org/mozilla-unified",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": True,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-unified",
+ "normalized": "https://hg.mozilla.org/mozilla-unified",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-unified",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "https",
+ "protocols": ["hg::https"],
+ "repo": "mozilla-unified",
+ "repo_name": "mozilla-unified",
+ "repo_path": "mozilla-unified",
+ "repo_type": "git",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-unified",
+ "https": "https://hg.mozilla.org/mozilla-unified",
+ "ssh": "ssh://hg.mozilla.org/mozilla-unified",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "hg::ssh://hg.mozilla.org/mozilla-unified",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": True,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-unified",
+ "normalized": "ssh://hg.mozilla.org/mozilla-unified",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-unified",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "ssh",
+ "protocols": ["hg::ssh"],
+ "repo": "mozilla-unified",
+ "repo_name": "mozilla-unified",
+ "repo_path": "mozilla-unified",
+ "repo_type": "git",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:ssh/mozilla-unified",
+ "https": "https://hg.mozilla.org/mozilla-unified",
+ "ssh": "ssh://hg.mozilla.org/mozilla-unified",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "hg://hg.mozilla.org/mozilla-central",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": True,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "hg://hg.mozilla.org:https/mozilla-central",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "hg",
+ "protocols": ["hg::https"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "git",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central",
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "hg://hg.mozilla.org:https/mozilla-central",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": True,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "hg://hg.mozilla.org:https/mozilla-central",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "hg",
+ "protocols": ["hg::https"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "git",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:https/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central",
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "hg://hg.mozilla.org:ssh/mozilla-central",
+ does_not_raise(),
+ {
+ "github": False,
+ "git_cinnabar": True,
+ "groups": [],
+ "hgmo": True,
+ "host": "hg.mozilla.org",
+ "name": "mozilla-central",
+ "normalized": "hg://hg.mozilla.org:ssh/mozilla-central",
+ "path_raw": "",
+ "path": "",
+ "pathname": "/mozilla-central",
+ "platform": "hgmo",
+ "port": "",
+ "protocol": "hg",
+ "protocols": ["hg::ssh"],
+ "repo": "mozilla-central",
+ "repo_name": "mozilla-central",
+ "repo_path": "mozilla-central",
+ "repo_type": "git",
+ "resource": "hg.mozilla.org",
+ "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
+ "urls": {
+ "hg": "hg://hg.mozilla.org:ssh/mozilla-central",
+ "https": "https://hg.mozilla.org/mozilla-central",
+ "ssh": "ssh://hg.mozilla.org/mozilla-central",
+ },
+ "user": "",
+ "valid": True,
+ },
+ ),
+ (
+ "https://some.unknown/repo",
+ pytest.raises(mozilla_repo_urls.InvalidRepoUrlError),
+ None,
+ ),
+ (
+ "https://gitlab.com/some-owner/some-repo",
+ pytest.raises(mozilla_repo_urls.UnsupportedPlatformError),
+ None,
+ ),
+ ),
+)
+def test_parse(url_string, expectation, expected):
+ with expectation:
+ url_object = mozilla_repo_urls.parse(url_string)
+ actual = {
+ attribute_name: getattr(url_object, attribute_name)
+ for attribute_name in expected.keys()
+ }
+ assert actual == expected