fix: read a citation wrapped before its colon

jgenesis, ioquake3, yquake2, playdiaemu, samcoupe, skyline and plastic wrap a citation as `path.ext` then `:N-M` on the next line. The collector only joined a line ending with a colon or comma, so these runs were never compared and a bump moved the pin past them silently. They are now read, as wrapped runs that hold the pin until rewritten.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 00:14:43 +02:00
1 parent 95d5c7b1ce
commit d62ada2e6e
2 files changed
+20

No files matched your search

+6
View File
@@ -305,6 +305,7 @@ PROSE_CITE_RE = re.compile(
r":(?P<range>\d+(?:-\d+)?)"
)
PROSE_LIST_ITEM_RE = re.compile(r"\d+[.)](?:\s|$)")
PROSE_WRAPPED_RANGE_RE = re.compile(r":\d+(?:-\d+)?(?:[,)\s]|$)")
PROSE_CONT_RE = re.compile(r",(?P<range>\d+(?:-\d+)?)(?![\w-])(?!\.\d)")
# A spaced continuation is accepted only for a range: `x.c:55-71, 80-147`
# follows the source_ref convention, while `x.c:100, 200 files` is prose.
@@ -464,6 +465,11 @@ def _prose_runs(
line = own.rstrip()
boundary = len(line)
following = lines[number + 1].lstrip() if number + 1 < len(lines) else ""
if PROSE_WRAPPED_RANGE_RE.match(following) and line[-1:].isalnum():
# The break can fall before the colon too: jgenesis wraps
# `.../src/config.rs` then `:76-78,95-99` on the next line.
line += following
following = ""
# A numbered list after a colon (abuse: `setup.cpp:` then `1. -datadir`)
# is not a range.
if not following[:1].isdigit() or PROSE_LIST_ITEM_RE.match(following):
+14
View File
@@ -3546,6 +3546,20 @@ class TestWrappedProse(unittest.TestCase):
{"libretro.cpp:2372-2373, 2429-2433": True, "c.c:5-6, 40-41": True},
)
def test_a_break_before_the_colon_is_read_whole(self):
# jgenesis wrote `(frontend/.../config.rs` then `:76-78,95-99)` on the
# next line, and the citation was never collected.
text = PROSE_SAMPLE.replace(
"files:",
"cfg: |\n Read from the config (src/config.rs\n :76-78,95-99) at start.\nfiles:",
)
runs = {
c.ref: c.wrapped
for c in profile_sync.collect_citations(yaml.safe_load(text))
if c.field == "cfg"
}
self.assertEqual(runs, {"src/config.rs:76-78,95-99": True})
def test_a_wrapped_run_that_moves_holds_the_pin(self):
parts = [
PartResult(RefPart("libretro.cpp", 2372, 2373, "2372-2373"),