mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: point source refs at paths held at the pin
trident cites the Panda3DS fork 3dsTrident vendors as a submodule, now its upstream at the submodule pin 69095ee6. pce-emu, uqm and stonesoup wrote paths from a subdirectory (PCE.emu/, sc2/, crawl-ref/), nesoid named two Java files without their directory; lines unchanged, each read at the pin. The pages no longer take a binary citation (DesktopKinect.dll, an address continuing a BAM.dll range) for a source path, and a Forgejo tree is read page by page: mirrors/Ryujinx holds 4704 entries, 1000 a page.
This commit is contained in:
1 parent
aeb68fe753
commit
36427edbb2
10 files changed
+198
-44
No files matched your search
+3
-24
@@ -46,6 +46,8 @@ from sourceref import ( # noqa: F401 (re-exported for callers and tests) # no
|
||||
_PROSE_LIST_DELIMITERS,
|
||||
_REF_RE,
|
||||
_SPLIT_RE,
|
||||
_BINARY_SUFFIXES,
|
||||
_HEX_ADDRESS_RE,
|
||||
PROSE_CITE_RE,
|
||||
PROSE_CONT_RE,
|
||||
PROSE_CONT_SPACED_RE,
|
||||
@@ -58,6 +60,7 @@ from sourceref import ( # noqa: F401 (re-exported for callers and tests) # no
|
||||
_prose_external,
|
||||
_prose_runs,
|
||||
_trim_prose,
|
||||
is_binary_citation,
|
||||
parse_source_ref,
|
||||
ref_prose_text,
|
||||
ref_role,
|
||||
@@ -195,33 +198,9 @@ def is_external_citation(path: str) -> bool:
|
||||
return "/" not in head and "." not in head
|
||||
|
||||
|
||||
_BINARY_SUFFIXES = (
|
||||
".dll", ".exe", ".so", ".dylib", ".apk", ".elf", ".o", ".a", ".jar", ".dex",
|
||||
)
|
||||
_HEX_ADDRESS_RE = re.compile(r"\b0x[0-9a-fA-F]{2,}")
|
||||
_VERSION_WORD_RE = re.compile(r"v?\d+(\.\d+)+[\w.-]*")
|
||||
|
||||
|
||||
def is_binary_citation(path: str) -> bool:
|
||||
"""True when a ref locates code inside a shipped binary, not a source file.
|
||||
|
||||
`BAM.dll 1.5-408 .text:0x100c3960-0x100c3a97`, `libmain.so LoadNES
|
||||
0x3bb49` and `.rdata dialog filter` were read by disassembly. No revision
|
||||
of any repository holds those bytes, so the ref can neither anchor nor
|
||||
break: 77 parts of `future-pinball-fploader` alone were reported GONE.
|
||||
"""
|
||||
if _HEX_ADDRESS_RE.search(path):
|
||||
return True
|
||||
if " " not in path:
|
||||
# A bare `DesktopKinect.dll` names a shipped library, never a source
|
||||
# file: no directory, no line, only its import table to read.
|
||||
return "/" not in path and path.lower().endswith(_BINARY_SUFFIXES)
|
||||
head = path.split(" ", 1)[0]
|
||||
if head.lower().endswith(_BINARY_SUFFIXES):
|
||||
return True
|
||||
return head.startswith(".") and "/" not in head
|
||||
|
||||
|
||||
def strip_repo_word(
|
||||
path: str, known: frozenset[str] | set[str] = frozenset()
|
||||
) -> str:
|
||||
|
||||
@@ -14,7 +14,9 @@ import urllib.request
|
||||
|
||||
import upstream
|
||||
from siterender import _by_mode
|
||||
from sourceref import _prose_runs, ref_role, source_ref_values, split_source_ref
|
||||
from sourceref import (
|
||||
_prose_runs, is_binary_citation, ref_role, source_ref_values, split_source_ref,
|
||||
)
|
||||
|
||||
|
||||
def _repo_pins(profile: dict, field: str, label: str) -> list[tuple[str, str, str]]:
|
||||
@@ -309,7 +311,10 @@ def _source_ref_markdown(profile: dict, value: str | dict | None) -> str:
|
||||
# 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):
|
||||
# A shipped binary (`DesktopKinect.dll`, `0x10037130-0x100371de`
|
||||
# continuing a BAM.dll range) is no path of either repository:
|
||||
# without a cached tree the single declared one took it.
|
||||
if path_re.fullmatch(part.path) and not is_binary_citation(part.path):
|
||||
if current_role:
|
||||
# Only the repository the part names, or no link at all.
|
||||
selected = by_role.get(current_role)
|
||||
|
||||
@@ -25,6 +25,32 @@ _LOCATED_RE = re.compile(r"^[^\s:]+:\d+(?:-\d+)?$")
|
||||
REPO_ROLES = ("source", "upstream")
|
||||
|
||||
|
||||
_BINARY_SUFFIXES = (
|
||||
".dll", ".exe", ".so", ".dylib", ".apk", ".elf", ".o", ".a", ".jar", ".dex",
|
||||
)
|
||||
_HEX_ADDRESS_RE = re.compile(r"\b0x[0-9a-fA-F]{2,}")
|
||||
|
||||
|
||||
def is_binary_citation(path: str) -> bool:
|
||||
"""True when a ref locates code inside a shipped binary, not a source file.
|
||||
|
||||
`BAM.dll 1.5-408 .text:0x100c3960-0x100c3a97`, `libmain.so LoadNES
|
||||
0x3bb49` and `.rdata dialog filter` were read by disassembly. No revision
|
||||
of any repository holds those bytes, so the ref can neither anchor nor
|
||||
break: 77 parts of `future-pinball-fploader` alone were reported GONE.
|
||||
"""
|
||||
if _HEX_ADDRESS_RE.search(path):
|
||||
return True
|
||||
if " " not in path:
|
||||
# A bare `DesktopKinect.dll` names a shipped library, never a source
|
||||
# file: no directory, no line, only its import table to read.
|
||||
return "/" not in path and path.lower().endswith(_BINARY_SUFFIXES)
|
||||
head = path.split(" ", 1)[0]
|
||||
if head.lower().endswith(_BINARY_SUFFIXES):
|
||||
return True
|
||||
return head.startswith(".") and "/" not in head
|
||||
|
||||
|
||||
def ref_role(path: str) -> tuple[str, str]:
|
||||
"""The role word a cited path opens with, and the path without it."""
|
||||
word, _, rest = path.partition(" ")
|
||||
|
||||
+18
-2
@@ -780,12 +780,28 @@ def list_tree(
|
||||
payload = _api(url, cache_dir, offline)
|
||||
if not isinstance(payload, dict):
|
||||
return [], True
|
||||
entries = list(payload.get("tree") or [])
|
||||
truncated = bool(payload.get("truncated"))
|
||||
# Forgejo pages a recursive tree, 1000 entries at a time, and says how
|
||||
# many there are: mirrors/Ryujinx holds 4704, and read as one page every
|
||||
# citation past the first thousand was unverifiable. GitHub reports no
|
||||
# count, its truncation is final.
|
||||
total = payload.get("total_count")
|
||||
if truncated and repo.family == "forgejo" and isinstance(total, int):
|
||||
for page in range(2, MAX_TREE_PAGES + 1):
|
||||
if len(entries) >= total:
|
||||
break
|
||||
more = _api(f"{url}&page={page}", cache_dir, offline)
|
||||
if not isinstance(more, dict) or not more.get("tree"):
|
||||
break
|
||||
entries.extend(more["tree"])
|
||||
truncated = len(entries) < total
|
||||
paths = [
|
||||
entry["path"]
|
||||
for entry in payload.get("tree") or []
|
||||
for entry in entries
|
||||
if isinstance(entry, dict) and entry.get("type") == "blob" and entry.get("path")
|
||||
]
|
||||
return paths, bool(payload.get("truncated"))
|
||||
return paths, truncated
|
||||
|
||||
|
||||
def list_gitlinks(
|
||||
|
||||
Reference in new issue
Block a user