apply: Order-independent subject sanitizing and case-insensitive trailer#12
Conversation
arighi
left a comment
There was a problem hiding this comment.
Looks good to me, same comment as the other PRs, if we can remove fix() from the subject and drop the no-mistakes file it'd be great, thanks!
|
|
||
| # Worktree root directory (relative to repo root or absolute path). | ||
| # Worktrees are placed under {root}/.treehouse/. Default: $HOME | ||
| # Example: root = "./" |
There was a problem hiding this comment.
Same as the other PRs and I understand now that this is some sort of automation (no-mistakes). I'm not familiar with it. I'm ok to use it, as long as there's a way to remove this file. :)
nirmoy
left a comment
There was a problem hiding this comment.
Blocking regression in sanitize_subject() at src/apply.rs:1581:
The fixpoint loop strips UBUNTU and SAUCE without requiring a delimiter. A concrete witness is:
SAUCE: UBUNTUFS: fix lookup -> FS: fix lookup
Before this change, stripping SAUCE: left UBUNTUFS: fix lookup; the new loop performs another iteration and incorrectly treats the start of UBUNTUFS as a tag. If the history contains that subject and the incoming title is FS: fix lookup, find_already_applied_in_log() can report an exact sanitized match and skip an unrelated cherry-pick.
Please strip a tag only when it is followed by :, whitespace, or end-of-string, and add this witness as a regression test.
Also remove the unrelated treehouse.toml addition. The follow-up no-mistakes(document) commit lacks the mandatory Signed-off-by; drop it or squash/amend the useful tests with a valid sign-off. Please also use the repository's subsystem subject style rather than fix(apply): ....
Validation performed: full suite passed (313 tests); subject matching, dependency detection, trailer rewriting, and cherry-pick skip callers were inspected.
sanitize_subject stripped UBUNTU/SAUCE prefixes in a single fixed-order pass, leaving non-canonical order or repeated tags unsanitized; it now strips to a fixpoint regardless of order. A prefix is only treated as a tag when a delimiter or end-of-string follows, so a subject such as "SAUCE: UBUNTUFS: fix lookup" is no longer collapsed to "FS: fix lookup" and mistaken for an already-applied commit by find_already_applied_in_log. Cherry-pick and backport trailer matching in referenced_commit_ids and backport_commit_message was case-sensitive; match the literal prefix case-insensitively while preserving the commit hash verbatim. Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
32381b6 to
e054921
Compare
Intent
Fix two narrow defects in boro's cherry-pick/backport handling (src/apply.rs). (1) sanitize_subject stripped UBUNTU/SAUCE kernel-subject prefixes in a single fixed-order pass, so subjects carrying the tags in a different order ('SAUCE: UBUNTU: ...') or repeated ('UBUNTU: UBUNTU: ...') were left partially sanitized; it now strips known prefixes to a fixpoint (loop until none matches), trimming ':'/space separators each pass, regardless of order or repetition, and leaves plain subjects untouched. (2) Cherry-pick/backport trailer matching in referenced_commit_ids and backport_commit_message used case-sensitive starts_with/strip_prefix, so a trailer with non-canonical casing ('(Cherry picked from commit )') was missed; added small ASCII case-insensitive helpers (strip_prefix_ignore_ascii_case is char-boundary safe via s.get(..len)) that match only the fixed literal prefix case-insensitively while preserving the commit hash and remainder VERBATIM. Shipped TDD tests for both defects (ordering/repetition cases, mixed-case + canonical trailer rewrite, mixed-case skip in referenced_commit_ids). Surgical upstream contribution to NVIDIA/boro: minimal change, behavior change ships tests, rustfmt clean, full suite green (312 tests).
What Changed
sanitize_subjectnow strips known kernel-subject prefixes (UBUNTU,SAUCE) to a fixpoint in a loop, trimming:/space separators each pass, so subjects with the tags in any order (SAUCE: UBUNTU: ...) or repeated (UBUNTU: UBUNTU: ...) are fully cleaned while plain subjects are left untouched.starts_with_ignore_ascii_case, char-boundary-safestrip_prefix_ignore_ascii_case) and used them inreferenced_commit_idsandbackport_commit_messageso non-canonical trailer casing like(Cherry picked from commit <sha>)is matched, with the commit hash and remainder preserved verbatim.referenced_commit_ids.Risk Assessment
✅ Low: Two narrow, well-bounded defect fixes with char-boundary-safe helpers, a provably-terminating fixpoint loop, no behavior regressions on existing inputs, and TDD tests covering each new case.
Testing
Ran the full boro test suite (313 passed, 0 failed) plus a focused run of every test touching the two fixed functions. The sanitize_subject fixpoint behavior and the case-insensitive trailer matching are covered by the shipped TDD tests. To exercise defect 2 at the product boundary rather than only the pure function, I added a real-git integration test that creates an actual repo, commits a mixed-case(Cherry picked from commit <sha>)trailer, runs boro's realrewrite_cherry_pick_trailer_as_backport(which doesgit commit --amend), and reads the resulting commit message back from git; it correctly becomes(backported from commit <sha>)with the hash preserved. I temporarily instrumented that test to dump the before/after commit message as a reviewer-visible artifact, then reverted the instrumentation. No UI surface is involved (Rust CLI internals), so evidence is CLI/test transcripts of the genuine git transformation. Worktree left clean aside from the intentional test addition.Evidence: Trailer rewrite before/after commit message (real git repo, mixed-case input)
---EVIDENCE before (HEAD commit message)--- subject (Cherry picked from commit 1111111222222233333334444444555555566666) ---EVIDENCE after (HEAD commit message)--- subject (backported from commit 1111111222222233333334444444555555566666)Evidence: Defect-relevant test transcript (sanitize_subject ordering/repetition + case-insensitive trailer)
test apply::tests::backport_commit_message_rewrites_mixed_case_cherry_pick_trailer ... ok test apply::tests::referenced_commit_ids_skips_mixed_case_cherry_pick_trailer ... ok test apply::tests::sanitize_subject_handles_any_order_and_repetition ... ok test apply::tests::rewrite_cherry_pick_trailer_as_backport_amends_mixed_case_trailer ... okEvidence: Full suite result
test result: ok. 313 passed; 0 failed; 0 ignored; 0 measured; 0 filtered outPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
cargo test --bin boro(full suite: 313 passed, 0 failed)cargo test --bin boro 'apply::tests::'filtered to sanitize_subject / backport_commit_message / referenced_commit_ids / rewrite_cherry_pick scenariosAdded real-git E2E testapply::tests::rewrite_cherry_pick_trailer_as_backport_amends_mixed_case_trailerdriving a mixed-case(Cherry picked from commit ...)trailer through the actualgit commit --amendcodepathCaptured before/after HEAD commit-message transcript via temporary --nocapture instrumentation (since reverted)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.