From 5bf25d19642b5005b56a8e67fe51fb49f544f54b Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:24:49 +0200 Subject: [PATCH] fix: move a ref only on a hash found elsewhere --- scripts/profile_sync.py | 4 ++-- tests/test_profile_sync.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index 9a70b771..ef0ba22a 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -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: diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index f2b503e2..61fca2b7 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -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")