From 104f54da7ff03ae217871a880c33506623ea8a7e Mon Sep 17 00:00:00 2001 From: mopgobopot Date: Fri, 16 Oct 2026 14:15:35 +0300 Subject: [PATCH] fix(tools): place resolved debt entries after their predecessor in the same file debt_split resolve anchored an added entry to the previous entry of the whole index. When that entry was in another section or another library's file, the new entry was appended to the end of its section instead of being placed before the entry it precedes. Co-Authored-By: Claude Opus 5.5 --- tools/debt_split.py | 2 +- tools/tests/test_debt_split.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/debt_split.py b/tools/debt_split.py index 6f8bfc054c..d6b0ef0793 100644 --- a/tools/debt_split.py +++ b/tools/debt_split.py @@ -197,7 +197,7 @@ def apply_change(root, base, new, index_text): for offset, fresh in enumerate(added): if offset in kept_new: continue - anchor = after[j1 + offset - 1] if j1 + offset > 0 else None + anchor = next((entry for entry in reversed(after[:j1 + offset]) if entry[1] == fresh[1] and entry[3] == fresh[3]), None) insert(fresh, anchor) for name, sections in files.items(): write_debt(root, name, sections, order) diff --git a/tools/tests/test_debt_split.py b/tools/tests/test_debt_split.py index 14eb2bac77..3596e47a76 100644 --- a/tools/tests/test_debt_split.py +++ b/tools/tests/test_debt_split.py @@ -198,6 +198,16 @@ class DebtSplitTests(unittest.TestCase): "\n\n### Functional\n\n" + A_FUNCTIONAL.replace("../../", "../../../") + "\n") self.assertEqual(self.read(INDEX), self.git("show", "main:" + INDEX).stdout) + def test_resolve_places_an_entry_inserted_at_the_top_of_a_later_section(self): + added = "- [libSceA](../../core/libs/prx/libSceA/Added.cpp) - `sceAAdded` returns 0" + result = self.rebase([A_STUB, B_STUB, C_STUB], [added, A_FUNCTIONAL, SHADER, SHARED]) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.git("rebase", "--continue") + self.assertEqual(self.read("docs/dev/debt/libSceA.md"), + "# libSceA technical debt\n\n### Silent stubs\n\n" + A_STUB.replace("../../", "../../../") + + "\n\n### Functional\n\n" + + "\n".join(entry.replace("../../", "../../../") for entry in (added, A_FUNCTIONAL)) + "\n") + def test_indented_continuation_after_a_blank_line_moves_with_its_entry(self): note = " - sub note about sceAOne" self.write(INDEX, "# Project technical debt\n\n### Silent stubs\n\n" + A_STUB + "\n\n" + note + "\n")