mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-21 19:29:03 -05:00
fix: a recale keeps the repository word of a ref
A source_ref written as `stella src/a.c:120` names the repository its lines are in. The path is read without the word, and --rebase-refs wrote the new span back without it, losing the attribution.
This commit is contained in:
1 parent
10a1f475b0
commit
adea35e12a
2 files changed
+26
No files matched your search
@@ -1996,6 +1996,12 @@ def _rendered_part(part: PartResult) -> str:
|
||||
if not raw:
|
||||
return span
|
||||
located = _trim_prose(_ANNOTATION_RE.sub("", raw).strip())
|
||||
# `stella src/emucore/Cart.cxx:120` names the repository the lines are
|
||||
# in. The path was read without that word, and a recale wrote it back
|
||||
# without it: the attribution went with the old line numbers.
|
||||
word, _, rest = located.partition(" ")
|
||||
if rest.startswith(f"{part.part.path}:") and word and "/" not in word:
|
||||
span = f"{word} {span}"
|
||||
if located and located in raw:
|
||||
return raw.replace(located, span, 1)
|
||||
return span
|
||||
|
||||
@@ -4268,5 +4268,25 @@ class AnOffForgeProfileWatchesItsReleasePage(unittest.TestCase):
|
||||
self.assertEqual(profile_sync.page_version(profile, "cache", False), "4.50")
|
||||
|
||||
|
||||
class ARecaleKeepsTheRepositoryWord(unittest.TestCase):
|
||||
"""`stella src/a.c:120` says the lines are in the stella repository. The
|
||||
path is read without the word, and a recale wrote it back without it."""
|
||||
|
||||
def test_the_word_stays_in_front_of_the_new_span(self):
|
||||
from sourceref import split_source_ref
|
||||
|
||||
for raw, expected in (
|
||||
("stella src/a.c:120-130", "stella src/a.c:140-150"),
|
||||
("stella src/a.c:120 (the table)", "stella src/a.c:140-150 (the table)"),
|
||||
("src/a.c:120", "src/a.c:140-150"),
|
||||
):
|
||||
with self.subTest(raw=raw):
|
||||
p = split_source_ref(raw)[0]
|
||||
part = profile_sync.RefPart(
|
||||
profile_sync.strip_repo_word(p.path, {"stella"}), p.start, p.end, p.raw)
|
||||
result = profile_sync.PartResult(part, "SHIFTED", None, 140, 150, [], "")
|
||||
self.assertEqual(profile_sync._rendered_part(result), expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user