Skip to content

[ci] Fix PR number parsing in get_contributors for cherry-picks and edge cases - #64354

Merged
elliot-barn merged 3 commits into
masterfrom
fix-get-contributors-pr-number-parsing
Jun 25, 2026
Merged

elliot-barn merged 3 commits into
masterfrom
fix-get-contributors-pr-number-parsing

Conversation

@sai-miduthuri

Copy link
Copy Markdown
Contributor

Description

The get_contributors release-notes script extracts PR numbers from commit subjects to look up contributor logins. The old _find_pr_number helper grabbed all text between (# and the first ), which produced wrong results for several real commit titles:

  • A truncated revert like Revert "... hot path (#6... (#64309) yielded 6... (#64309 instead of 64309.
  • A title carrying a fixed-issue reference followed by the merging PR, e.g. ... cpu_percent (#63729) (#63733), yielded the issue number 63729 instead of the PR 63733.
  • Cherry-picks such as ... in MiB (#63932) (#64042) (original PR + backport PR) credited only one number, silently dropping the original author.

This PR replaces it with _find_pr_numbers, which:

  • Matches only well-formed (#<digits>) tokens using a module-level compiled regex (the helper runs up to thousands of times per invocation).
  • Returns every candidate in title order. The commit text alone cannot tell an issue from a PR or an original from a backport, so run queries all candidates via the GitHub API and credits each one that resolves as a real PR. A cherry-pick now credits both the original author and the backporter.
  • Treats a 404 as expected (the number is an issue, not a PR) and collects those numbers, printing them at the end. This way, if GitHub's behavior ever changes and a real PR starts returning 404, the dropped numbers are surfaced rather than silently lost.

Related issues

N/A

Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR, cherry-pick, non-digit parentheticals) and the CLI behavior (both cherry-pick authors credited; an issue 404 does not drop the real PR author and is reported in the output).

🤖 Generated with Claude Code

…dge cases

The `_find_pr_number` helper captured all text between `(#` and the first
`)`, so titles like a truncated revert (`...(#6... (#64309)`) yielded
`6... (#64309` and `(#issue) (#pr)` titles yielded the fixed issue number
instead of the merging PR.

Replace it with `_find_pr_numbers`, which matches only well-formed
`(#<digits>)` tokens via a module-level compiled regex and returns every
candidate. The text alone cannot distinguish an issue from a PR or an
original from a backport, so `run` now queries all candidates and credits
every one that resolves as a real PR. This ensures a cherry-pick credits
both the original author and the backporter rather than silently dropping
the original author.

Numbers that 404 (expected for issue references) are collected and printed
at the end so a future change in GitHub's behavior surfaces instead of
silently dropping a contributor.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: sai.miduthuri <[email protected]>
@sai-miduthuri
sai-miduthuri requested a review from a team as a code owner June 25, 2026 21:17

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the contributor extraction script to parse multiple PR and issue numbers from commit messages, which is particularly useful for cherry-picks and backports. It replaces the single PR parser with a regex-based multi-PR parser and improves error handling for non-PR references. The review feedback suggests two key improvements: simplifying the PR number extraction by running the parser directly on the entire commits string, and parallelizing the GitHub API requests using a ThreadPoolExecutor to significantly boost performance.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Run _find_pr_numbers directly on the full commits string instead of
looping over lines, since re.findall already scans across newlines. Add a
test covering multiple commit titles passed in a single blob.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: sai.miduthuri <[email protected]>
@sai-miduthuri sai-miduthuri added the go add ONLY when ready to merge, run all tests label Jun 25, 2026
Address code-review findings on get_contributors:

- Non-404 GitHub API errors (rate limit, 5xx, network) previously printed
  and continued, silently dropping a real contributor while the script
  still exited 0. Collect these numbers and raise a ClickException at the
  end so the operator knows the contributor list is incomplete.
- Document the union-parsing trade-off: keeping every "(#N)" reference also
  credits PRs merely mentioned in prose (e.g. the reverted PR in a revert
  commit). This is accepted to avoid ever missing a real contributor.
- Refresh the now-stale module comment (the regex is no longer called "a
  thousand times"; it runs once on the whole blob) and rename the
  _find_pr_numbers param from `line` to `text` to match its actual usage.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: sai.miduthuri <[email protected]>
@elliot-barn
elliot-barn merged commit e740785 into master Jun 25, 2026
3 checks passed
@elliot-barn
elliot-barn deleted the fix-get-contributors-pr-number-parsing branch June 25, 2026 23:44
limarkdcunha pushed a commit to limarkdcunha/ray that referenced this pull request Jun 30, 2026
…dge cases (ray-project#64354)

## Description

The `get_contributors` release-notes script extracts PR numbers from
commit subjects to look up contributor logins. The old `_find_pr_number`
helper grabbed all text between `(#` and the first `)`, which produced
wrong results for several real commit titles:

- A truncated revert like `Revert "... hot path (ray-project#6... (ray-project#64309)` yielded
`6... (ray-project#64309` instead of `64309`.
- A title carrying a fixed-issue reference followed by the merging PR,
e.g. `... cpu_percent (ray-project#63729) (ray-project#63733)`, yielded the issue number
`63729` instead of the PR `63733`.
- **Cherry-picks** such as `... in MiB (ray-project#63932) (ray-project#64042)` (original PR +
backport PR) credited only one number, silently dropping the original
author.

This PR replaces it with `_find_pr_numbers`, which:

- Matches only well-formed `(#<digits>)` tokens using a module-level
compiled regex (the helper runs up to thousands of times per
invocation).
- Returns **every** candidate in title order. The commit text alone
cannot tell an issue from a PR or an original from a backport, so `run`
queries all candidates via the GitHub API and credits each one that
resolves as a real PR. A cherry-pick now credits both the original
author and the backporter.
- Treats a `404` as expected (the number is an issue, not a PR) and
collects those numbers, printing them at the end. This way, if GitHub's
behavior ever changes and a real PR starts returning `404`, the dropped
numbers are surfaced rather than silently lost.

## Related issues

N/A

## Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR,
cherry-pick, non-digit parentheticals) and the CLI behavior (both
cherry-pick authors credited; an issue `404` does not drop the real PR
author and is reported in the output).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: sai.miduthuri <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…dge cases (ray-project#64354)

## Description

The `get_contributors` release-notes script extracts PR numbers from
commit subjects to look up contributor logins. The old `_find_pr_number`
helper grabbed all text between `(#` and the first `)`, which produced
wrong results for several real commit titles:

- A truncated revert like `Revert "... hot path (ray-project#6... (ray-project#64309)` yielded
`6... (ray-project#64309` instead of `64309`.
- A title carrying a fixed-issue reference followed by the merging PR,
e.g. `... cpu_percent (ray-project#63729) (ray-project#63733)`, yielded the issue number
`63729` instead of the PR `63733`.
- **Cherry-picks** such as `... in MiB (ray-project#63932) (ray-project#64042)` (original PR +
backport PR) credited only one number, silently dropping the original
author.

This PR replaces it with `_find_pr_numbers`, which:

- Matches only well-formed `(#<digits>)` tokens using a module-level
compiled regex (the helper runs up to thousands of times per
invocation).
- Returns **every** candidate in title order. The commit text alone
cannot tell an issue from a PR or an original from a backport, so `run`
queries all candidates via the GitHub API and credits each one that
resolves as a real PR. A cherry-pick now credits both the original
author and the backporter.
- Treats a `404` as expected (the number is an issue, not a PR) and
collects those numbers, printing them at the end. This way, if GitHub's
behavior ever changes and a real PR starts returning `404`, the dropped
numbers are surfaced rather than silently lost.

## Related issues

N/A

## Additional information

Unit tests cover the parsing edge cases (truncated revert, issue+PR,
cherry-pick, non-digit parentheticals) and the CLI behavior (both
cherry-pick authors credited; an issue `404` does not drop the real PR
author and is reported in the output).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: sai.miduthuri <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants