Skip to content

pr_review.py reply --match: a pattern copied from a printed unresolved: line can still miss its own thread #1877

Description

@ptr727

Context

Split out of #1299 during its own local-strict-review pass, which flagged this as a related but out-of-scope gap in the same fix.

The defect

reply_to_thread() prints each unresolved thread via describe(), which collapses the thread body's whitespace to single spaces (" ".join(body.split())) and truncates it to 120 characters before printing it as the unresolved: line a NO_MATCH refusal shows.

matching_threads() itself compares --match against the thread's raw, uncollapsed, untruncated body.

So a --match string copied verbatim from one of those printed unresolved: lines can still return NO_MATCH, in two ways:

  • The pattern spans a point in the body that carried a line break, tab, or run of multiple spaces in the original, now printed back as a single space; the raw body still carries the original whitespace, so the collapsed substring is not literally present in it.
  • The pattern is copied at or past the 120-character cutoff, past which the printed line carries nothing to copy from at all.

This is the same shape of failure #1299 fixed: a --match string that a caller copied straight from what this script itself printed still fails to select the thread it was copied from.

Suggested fix

Worth considering: fold whitespace the same way on both sides before the substring compare (matching describe()'s own collapse), so a pattern copied from the printed line matches the same way the original would have. The 120-character truncation is a display concern rather than a matching one and may not need a corresponding change beyond documenting the limit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scriptA defect in hub tooling

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions