From 7fd82d452f4926fba21c09e731e2958d3537c40e Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 17 Oct 2026 15:37:23 +0200 Subject: [PATCH] fix: read gitlab subgroup repositories whole --- scripts/upstream.py | 10 ++++++++-- tests/test_upstream.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/upstream.py b/scripts/upstream.py index ed855fb4..253629bd 100644 --- a/scripts/upstream.py +++ b/scripts/upstream.py @@ -138,12 +138,18 @@ def parse_repo(url: str) -> Repo | None: if entry is None: return None segments = [s for s in parts.path.split("/") if s] + family, api_base, raw_base = entry + if family == "gitlab" and "-" in segments: + # GitLab nests projects in subgroups; "/-/" opens the project's pages. + segments = segments[: segments.index("-")] if len(segments) < 2: return None - owner, name = segments[0], segments[1] + if family == "gitlab": + owner, name = "/".join(segments[:-1]), segments[-1] + else: + owner, name = segments[0], segments[1] if name.endswith(".git"): name = name[:-4] - family, api_base, raw_base = entry return Repo(parts.netloc, family, api_base, raw_base, owner, name) diff --git a/tests/test_upstream.py b/tests/test_upstream.py index ded955f3..bebdcaa6 100644 --- a/tests/test_upstream.py +++ b/tests/test_upstream.py @@ -54,6 +54,18 @@ class TestParseRepo(unittest.TestCase): repo = parse_repo("https://gitlab.com/recalbox/recalbox") self.assertEqual(repo.family, "gitlab") + def test_gitlab_subgroup_keeps_the_whole_namespace(self): + repo = parse_repo( + "https://gitlab.com/recalbox/packages/standalone/rb5000/-/tree/main" + ) + self.assertEqual(repo.owner, "recalbox/packages/standalone") + self.assertEqual(repo.name, "rb5000") + self.assertEqual( + raw_url(repo, "abc123", "source/Engine.cpp"), + "https://gitlab.com/recalbox/packages/standalone/rb5000" + "/-/raw/abc123/source/Engine.cpp", + ) + def test_libretro_gitlab_is_a_gitlab(self): repo = parse_repo("https://git.libretro.com/libretro/wqxemu.git") self.assertEqual(repo.family, "gitlab")