Add Contributor Compilation Tool for Release Notes (#27284)
## Summary
This PR introduces a new tool, `compile_contributors.py`, designed to
automate and improve the accuracy of contributor attribution for ONNX
Runtime release notes. It accurately identifies original authors even in
complex scenarios involving release cherry-pick rounds and meta-PRs.
## Key Features
### 1. Robust Meta-PR & Cherry-Pick Expansion
- **Recursive Expansion**: The script automatically detects "Cherry-pick
round" meta-PRs and recursively expands them by extracting original PR
numbers from titles, bodies, and commit messages using the GitHub CLI
(`gh`).
- **Accurate Filtering**: Refined regex logic ensures that only Pull
Requests are extracted, explicitly ignoring Issue URLs (e.g., 26985) to
ensure code attribution is tied to the authors.
### 2. High-Fidelity Contributor Attribution
- **Case-Insensitive Consolidation**: Deduplicates contributors by
normalizing GitHub logins case-insensitively, while preserving the
first-seen casing for display.
- **Author Fallback**: If an original PR's metadata is unavailable
(e.g., private or deleted), the tool automatically falls back to the
Meta-PR's authors or the Git commit author to ensure no contribution is
missed.
- **Bot Filtering**: Includes a comprehensive list of known bots to
ensure the final summary reflects human contributors only.
### 3. Traceability & Output
- **Detailed Execution Logs**: Generates a `logs.txt` file in the output
directory, providing a step-by-step audit trail of why every PR was
included, expanded, or skipped.
- **Auditable CSV Details**: Produces a `detail.csv` mapping every
change to its original PR, title, authors, and target commit.
- **Configurable Control**: Added `--scan-depth` argument to allow users
to control the lookback window for deduplication or meta-PR expansion
analysis.
- **GitHub-Optimized Summary**: Prints a professional, markdown-ready
contributor list to both the console and logs. It uses single-line
formatting to allow GitHub's GFM to handle responsive wrapping naturally
in release notes.
## Verification
The tool has been validated across several release scenarios:
- **Verified Issue Filtering**: Confirmed that issues like 26985 are
ignored during expansion, even when mentioned in titles.
- **Verified Expansion**: Successfully expanded meta-PRs like 25563 into
underlying work (e.g., 25544).
- **Verified Security**: Confirmed that `shell=False` handling prevents
command injection via branch names.
## Usage
```powershell
python tools/python/compile_contributors.py --base <base_ref> --target <target_ref> --dir <output_dir> --scan-depth 100
```
**Requirements**:
- GitHub CLI (`gh`) must be installed and authenticated.
- Python 3.7+ (uses `capture_output`)
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>