fix(tools): keep a debt file's note and sub-headings when debt_split rewrites it #13957
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13957"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T13:56:30Z.
What
tools/debt_split.pyrewrites a library's debt file when it moves entries into it. Two cases lost hand-written text:read_debtkept only the entries and paragraphs under a###heading. A note before the first###and every####heading were dropped on rewrite. Reproduced: alibSceFoo.mdwith the note "Hand-written note about foo that must stay." and a#### Detail headinglost both afterdebt_split.py splitadded one entry.write_debtdeleted a debt file when none of its sections had entries, so a file that held only a note disappeared.The fix keeps the note and the
####headings. A newread_preamblereads what comes before the first###(the file's#title excepted),renderandwrite_debtwrite it back after the title, andapply_changecarries it throughresolve.####headings inside a section are kept in that section.read_debtstill returns the same dictionary for the same files.A second case, found while reproducing: an entry above the first
###of the index was filed under a literal### Nonesection in its library's file.splitnow stops withan entry is above the first ### section, so there is no section to file it under: ...and writes nothing.Tested
Linux, Python 3.11.2, this branch at
4f5c2bab39onupstream/main73f4f7e06e:python3 tools/tests/test_debt_split.py: 31 tests, OK. The 28 existing tests plus three new ones:test_split_keeps_the_note_and_sub_headings_of_an_existing_debt_file,test_a_debt_file_with_only_a_note_is_written_and_not_deletedandtest_split_refuses_an_entry_above_the_first_section_without_writing.####heading survive, and the entry above the first section is refused with exit 1.python3 tools/check_conventions.py --base upstream/main: all conventions checks passed.git diff --check upstream/main HEAD: clean.tools/pr_overlap.py --branch: no overlap with open pull requests.Negative control: the three new tests run against the
upstream/maindebt_split.pyfail, as intended (the note and heading are dropped, the entry above the first section is filed under### None, andwrite_debthas no preamble argument, so the empty-section test errors).Not run: the C++ build and CTest (no C++ changed); Windows, macOS and hosted CI are not run locally.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:58:27Z.
Review: COMMENTED
Reviewed — order proposal checked, one test file named in the reply is missing
janzezno's 2026-10-31 proposal (this PR first, #14212 rebased on it) is consistent with the code at this head, but the reply cites a test file that exists neither here nor on main.
What I ran
Live head
4f5c2bab3992fd5baaf7ee73e02e1bd6536715f7(matches the batch file). Read the comment withgh api repos/boykopovar/AnyPS5/issues/13957/comments, the check rollup withgh pr view 13957 --json statusCheckRollup, and the files withgit -C /marc/AnyPS5 show <ref>:<path>at the head and at381891927c. Nothing was built or run.Results
Findings
The reply (2026-10-31T23:47:09Z) says #14212 changes the same line of
write_debtand asks whether this PR goes first.render(title, sections, order, preamble=())takespreamble(tools/debt_split.pyline 141). At381891927cit does not (def render(title, sections, order):, line 141). So this PR is the one that adds it.write_debtcallsrender(f"# {name} technical debt", sections, order, preamble)at line 190, the line the reply's snippet wraps.space_debtis not defined anywhere in the tree at this head, so it can only come from #14212. Not verified.tools/tests/test_debt_format.pypasses on the merge. That file exists neither at this head nor at381891927c, so the stated test run cannot be checked as written. The reply'stest_debt_split.pyclaim is not re-run.Answer: nothing at this head contradicts the order. The conflict is the one line described. Before agreeing, confirm which test file was run.
Sources
github.com/boykopovar/AnyPS5@4f5c2bab39/tools/debt_split.py (L141-L149)github.com/boykopovar/AnyPS5@4f5c2bab39/tools/debt_split.py (L182-L190)github.com/boykopovar/AnyPS5@4f5c2bab39/tools/tests/test_debt_split.py (L474-L500)Not verified
space_debtand #14212's own diff.381891927c(not re-run).