Summary
Detect clean rebases on PR synchronize events and preserve review labels instead of stripping them unnecessarily.
Problem / Motivation
When a PR is synchronized (new commits pushed), the server currently strips all review-related labels (approved-by-*, lgtm-by-*, changes-requested-by-*, commented-by-*). This is correct for actual code changes, but unnecessary for clean rebases where no code was actually modified — just commits replayed on a newer base.
This forces reviewers to re-approve PRs that had no actual changes, wasting time.
Solution
Detect clean rebases by comparing the diff against the base branch before and after the force push. If the diffs are identical, it's a clean rebase.
Detection method: Compare SHA-256 hashes of git diff <merge-base>..<head> before and after the synchronize event. Same hash = clean rebase.
On clean rebase detected:
- Preserve review labels:
approved-by-*, lgtm-by-*, verified-*
- Post a PR comment explaining that a clean rebase was detected and which labels were preserved
- Continue all other synchronize processing normally (CI, size check, etc.)
Requirements
- Add a clean rebase detection method that compares SHA-256 hashes of
git diff <merge-base>..<head> before and after the synchronize event
- Modify
remove_labels_when_pull_request_sync() to skip label removal when a clean rebase is detected
- Post a PR comment listing preserved labels when a clean rebase is detected
- Ensure all other synchronize processing (CI, size check, etc.) continues normally regardless of rebase detection
Deliverables
Notes
- The
before and after SHAs are available in the webhook synchronize event payload
- The repository clone is already available during synchronize processing, so
git diff can be run locally
- This optimization is particularly valuable for large PRs with many approvals
Summary
Detect clean rebases on PR synchronize events and preserve review labels instead of stripping them unnecessarily.
Problem / Motivation
When a PR is synchronized (new commits pushed), the server currently strips all review-related labels (
approved-by-*,lgtm-by-*,changes-requested-by-*,commented-by-*). This is correct for actual code changes, but unnecessary for clean rebases where no code was actually modified — just commits replayed on a newer base.This forces reviewers to re-approve PRs that had no actual changes, wasting time.
Solution
Detect clean rebases by comparing the diff against the base branch before and after the force push. If the diffs are identical, it's a clean rebase.
Detection method: Compare SHA-256 hashes of
git diff <merge-base>..<head>before and after the synchronize event. Same hash = clean rebase.On clean rebase detected:
approved-by-*,lgtm-by-*,verified-*Requirements
git diff <merge-base>..<head>before and after the synchronize eventremove_labels_when_pull_request_sync()to skip label removal when a clean rebase is detectedDeliverables
git diff+ SHA-256 hash comparisonremove_labels_when_pull_request_sync()to skip label removal on clean rebaseNotes
beforeandafterSHAs are available in the webhooksynchronizeevent payloadgit diffcan be run locally