fix: move a ref only on a hash found elsewhere

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 09:24:49 +02:00
1 parent cdecb096a1
commit 5bf25d1964
2 files changed
+13 -2

No files matched your search

+2 -2
View File
@@ -1183,8 +1183,8 @@ def verify_at_pin(part: RefPart, pin_lines, tokens, hash_tokens=()) -> PartResul
{
index
for index, line in enumerate(pin_lines, 1)
for token in tokens
if token in line.lower()
for token in hash_tokens
if token.lower() in line.lower()
}
)
if not elsewhere:
+11
View File
@@ -415,6 +415,17 @@ class TestVerifyAtPin(unittest.TestCase):
self.assertEqual(result.status, "MOVED")
self.assertEqual(result.start, 7)
def test_a_name_stem_elsewhere_does_not_move_a_ref(self):
"""linapple cites the PRAVETS82 option; the stem also names an install line."""
lines = ['option(ENABLE_ROM_CLONE_PRAVETS "" OFF)', "", "", "", "", "",
"", "", "", "", "", "", "res/roms/pravets82.rom"]
part = RefPart("CMakeLists.txt", 1, 1, "CMakeLists.txt:1")
result = profile_sync.verify_at_pin(
part, lines, ["0123456789abcdef0123456789abcdef", "pravets82"],
["0123456789abcdef0123456789abcdef"],
)
self.assertEqual(result.status, "ANCHORED")
def test_declared_value_on_several_lines_is_ambiguous(self):
lines = ["load()", "", "", "", 'a("cafebabe")', "", 'b("cafebabe")']
part = RefPart("a.c", 1, 1, "a.c:1")