mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-21 19:29:03 -05:00
fix: link source paths as the profiles write them
This commit is contained in:
1 parent
56105fc108
commit
6490cc6613
2 files changed
+15
-11
No files matched your search
@@ -140,17 +140,14 @@ def _source_ref_markdown(profile: dict, value: str | dict | None) -> str:
|
||||
if part.end is not None and part.end != part.start:
|
||||
display += f"-{part.end}"
|
||||
|
||||
# The path is linked as written. A first segment equal to a
|
||||
# repository's name proves nothing: PCSX2 keeps its sources in
|
||||
# pcsx2/, hatariB vendors Hatari in hatari/, and stripping it
|
||||
# broke 470 links. Two repositories and no tree to read: no link.
|
||||
selected: tuple[upstream.Repo, str] | None = None
|
||||
real_path = part.path
|
||||
if path_re.fullmatch(part.path) and candidates:
|
||||
for repo, pin in candidates:
|
||||
prefix = f"{repo.name}/"
|
||||
if part.path.startswith(prefix):
|
||||
selected = (repo, pin)
|
||||
real_path = part.path[len(prefix):]
|
||||
break
|
||||
if selected is None and len(candidates) == 1:
|
||||
selected = candidates[0]
|
||||
if path_re.fullmatch(part.path) and len(candidates) == 1:
|
||||
selected = candidates[0]
|
||||
|
||||
if selected is None:
|
||||
rendered.append(f"`{display}`")
|
||||
|
||||
@@ -162,9 +162,16 @@ class SiteReferenceContracts(unittest.TestCase):
|
||||
self.assertEqual(rendered, "`jg.c:213-214`")
|
||||
self.assertNotIn("http", rendered)
|
||||
|
||||
# A repository-name prefix removes the ambiguity, so it links again.
|
||||
# A first segment equal to a repository's name proves nothing: PCSX2
|
||||
# keeps its sources in pcsx2/, hatariB vendors Hatari in hatari/.
|
||||
# Stripped, 470 links pointed at nothing or at another file.
|
||||
prefixed = _source_ref_markdown(profile, "example/jg.c:213-214")
|
||||
self.assertIn("gitlab.com/vendor/example/-/blob/" + "b" * 40 + "/jg.c", prefixed)
|
||||
self.assertEqual(prefixed, "`example/jg.c:213-214`")
|
||||
|
||||
def test_a_single_repository_links_the_path_as_written(self):
|
||||
profile = {"source": "https://github.com/PCSX2/pcsx2", "source_commit": "c" * 40}
|
||||
rendered = _source_ref_markdown(profile, "pcsx2/ImGui/FullscreenUI.cpp:755-759")
|
||||
self.assertIn("/blob/" + "c" * 40 + "/pcsx2/ImGui/FullscreenUI.cpp#L755-L759", rendered)
|
||||
|
||||
def test_preprocessor_tokens_cannot_become_page_headings(self):
|
||||
rendered = _admonition_body("First paragraph.\n\n#if FEATURE\nEnabled")
|
||||
|
||||
Reference in new issue
Block a user