Skip to content

apply: Order-independent subject sanitizing and case-insensitive trailer#12

Merged
arighi merged 1 commit into
NVIDIA:mainfrom
nethum529:fix/cherry-pick-trailer-and-sanitize
Jul 3, 2026
Merged

apply: Order-independent subject sanitizing and case-insensitive trailer#12
arighi merged 1 commit into
NVIDIA:mainfrom
nethum529:fix/cherry-pick-trailer-and-sanitize

Conversation

@nethum529

Copy link
Copy Markdown
Contributor

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_subject now 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.
  • Added ASCII case-insensitive helpers (starts_with_ignore_ascii_case, char-boundary-safe strip_prefix_ignore_ascii_case) and used them in referenced_commit_ids and backport_commit_message so non-canonical trailer casing like (Cherry picked from commit <sha>) is matched, with the commit hash and remainder preserved verbatim.
  • Added unit and real-git E2E tests covering prefix ordering/repetition, mixed-case and canonical trailer rewrites, the no-trailer no-op, and mixed-case skipping in 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 &lt;sha&gt;) trailer, runs boro's real rewrite_cherry_pick_trailer_as_backport (which does git commit --amend), and reads the resulting commit message back from git; it correctly becomes (backported from commit &lt;sha&gt;) 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 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 ... ok

test apply::tests::backport_commit_message_noops_on_message_without_trailer ... ok
test apply::tests::backport_commit_message_noops_without_cherry_pick_trailer ... ok
test apply::tests::backport_commit_message_rewrites_canonical_lowercase_cherry_pick_trailer ... ok
test apply::tests::backport_commit_message_rewrites_mixed_case_cherry_pick_trailer ... ok
test apply::tests::backport_commit_message_rewrites_only_cherry_pick_trailer ... ok
test apply::tests::referenced_commit_ids_extracts_and_dedups_hex_tokens ... ok
test apply::tests::referenced_commit_ids_skips_mixed_case_cherry_pick_trailer ... ok
test apply::tests::sanitize_subject_drops_ubuntu_and_sauce_prefixes ... 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 ... ok
test apply::tests::rewrite_cherry_pick_trailer_as_backport_amends_head_message ... ok
Evidence: Full suite result

test result: ok. 313 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

test lore::tests::master_fixes_skipped_when_already_applied_to_review_tip ... ok
test tools::tests::truncate_diff_respects_max_tool_output ... ok
test lore::tests::master_fixes_skipped_when_cherry_pick_subject_is_applied ... ok
test tools::tests::smart_output_respects_max_tool_output ... ok
test api::tests::request_input_budget_trims_initial_user_and_preserves_tail ... ok

test result: ok. 313 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s

Pipeline

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 &#39;apply::tests::&#39; filtered to sanitize_subject / backport_commit_message / referenced_commit_ids / rewrite_cherry_pick scenarios
  • Added real-git E2E test apply::tests::rewrite_cherry_pick_trailer_as_backport_amends_mixed_case_trailer driving a mixed-case (Cherry picked from commit ...) trailer through the actual git commit --amend codepath
  • Captured 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.

@arighi arighi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread treehouse.toml Outdated

# Worktree root directory (relative to repo root or absolute path).
# Worktrees are placed under {root}/.treehouse/. Default: $HOME
# Example: root = "./"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 nirmoy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@nethum529 nethum529 force-pushed the fix/cherry-pick-trailer-and-sanitize branch from 32381b6 to e054921 Compare July 1, 2026 19:58
@nethum529 nethum529 changed the title fix(apply): order-independent subject sanitizing and case-insensitive cherry-pick trailers apply: Order-independent subject sanitizing and case-insensitive trailer Jul 1, 2026
@arighi arighi merged commit 66111c7 into NVIDIA:main Jul 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants