This commit optimizes `scripts/review_pull_requests.py` by implementing bulk
metadata retrieval for Git branches.
Key improvements:
- Reduced subprocess calls from O(N) to O(1) for branch metadata (ahead/behind,
last commit date, subject) using `git for-each-ref`.
- Implemented `get_git_version()` for safe usage of the `%(ahead-behind)` atom
(introduced in Git 2.41).
- Added a `BRANCH_METADATA_CACHE` to eliminate redundant `git log` calls.
- Maintained full compatibility with older Git versions via a robust fallback path.
- Preserved output parity with the original script.
Performance impact:
- Execution time reduced from ~2.3s to ~0.56s (~76% improvement) in an
environment with 315 remote branches.