From 963fc55ee28781c8e91a516a57d026082a8f050c Mon Sep 17 00:00:00 2001 From: Garry Dixon Date: Thu, 1 Dec 2022 15:51:03 +0000 Subject: [PATCH 1/3] Check for /-/ in GitLab url (closes #1073) Make sure the /-/ string exists in path before splitting the path to avoid exception --- src/pydata_sphinx_theme/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 93d747d16..0176b81ad 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -1007,7 +1007,7 @@ def parse_url(self, uri): elif self.platform == "gitlab": # cp. https://docs.gitlab.com/ee/user/markdown.html#gitlab-specific-references - if any(map(uri.path.__contains__, ["issues", "merge_requests"])): + if "/-/" in path and any(map(uri.path.__contains__, ["issues", "merge_requests"])): group_and_subgroups, parts, *_ = path.split("/-/") parts = parts.split("/") url_type, element_number, *_ = parts From f742515ffacc88f7751bcfa2d77507ac9033c84f Mon Sep 17 00:00:00 2001 From: Garry Dixon Date: Thu, 1 Dec 2022 16:06:26 +0000 Subject: [PATCH 2/3] Adjust formatting to fit line length --- src/pydata_sphinx_theme/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 0176b81ad..313ee522b 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -1007,7 +1007,9 @@ def parse_url(self, uri): elif self.platform == "gitlab": # cp. https://docs.gitlab.com/ee/user/markdown.html#gitlab-specific-references - if "/-/" in path and any(map(uri.path.__contains__, ["issues", "merge_requests"])): + if "/-/" in path and any( + map(uri.path.__contains__, ["issues", "merge_requests"]) + ): group_and_subgroups, parts, *_ = path.split("/-/") parts = parts.split("/") url_type, element_number, *_ = parts From b76f706f8c34c0b2f22c4c94d50b10239765f3e0 Mon Sep 17 00:00:00 2001 From: Garry Dixon Date: Thu, 1 Dec 2022 18:23:57 +0000 Subject: [PATCH 3/3] Add non-standard GitLab Url test --- tests/sites/base/page1.rst | 1 + tests/test_build/gitlab_links.html | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/sites/base/page1.rst b/tests/sites/base/page1.rst index 79cb11dee..4e9a3ee9d 100644 --- a/tests/sites/base/page1.rst +++ b/tests/sites/base/page1.rst @@ -23,6 +23,7 @@ Page 1 https://gitlab.com/gitlab-org https://gitlab.com/gitlab-org/gitlab https://gitlab.com/gitlab-org/gitlab/-/issues/375583 + https://gitlab.com/gitlab-org/gitlab/issues/375583 https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84669 https://gitlab.com/gitlab-org/gitlab/-/pipelines/511894707 https://gitlab.com/gitlab-com/gl-infra/production/-/issues/6788 diff --git a/tests/test_build/gitlab_links.html b/tests/test_build/gitlab_links.html index e93a4db50..48f0530ed 100644 --- a/tests/test_build/gitlab_links.html +++ b/tests/test_build/gitlab_links.html @@ -12,6 +12,9 @@ gitlab-org/gitlab#375583 + + gitlab-org/gitlab/issues/375583 + gitlab-org/gitlab!84669