Skip to content

fix: normalize bot email matching and preserve squash author#94

Open
RadekManak wants to merge 1 commit into
openshift-eng:mainfrom
RadekManak:feature-rebasebot-bot-emails
Open

fix: normalize bot email matching and preserve squash author#94
RadekManak wants to merge 1 commit into
openshift-eng:mainfrom
RadekManak:feature-rebasebot-bot-emails

Conversation

@RadekManak

@RadekManak RadekManak commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • normalize bot email matching so GitHub noreply-style addresses like 12345+bot@example.com still match --bot-emails
  • keep real plus-addressed emails distinct instead of collapsing them into one bot identity
  • preserve the original author when squashing bot commits
  • add a regression test covering both email normalization cases

Why

Rebasebot normalized bot emails from commits differently than emails passed in --bot-emails, which could prevent expected bot commit squashing. This change makes matching consistent while avoiding false matches for real plus-addressed emails.

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection and matching of bot-generated commits during rebases by normalizing GitHub-style noreply committer emails.
    • Preserved the correct original author information when squashing bot commits, so attribution remains accurate.
    • Fixed email normalization to keep real +tag addresses intact while properly recognizing bot-style noreply formats.
  • Tests
    • Added coverage for squashing bot commits with numeric + committer email forms and verifying the resulting commit attribution and graph structure.

@openshift-ci openshift-ci Bot requested review from mdbooth and racheljpg June 24, 2026 10:16
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RadekManak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c03b2e11-c950-4950-8766-dcd7ee0263a4

📥 Commits

Reviewing files that changed from the base of the PR and between 07b41e3 and a68b86c.

📒 Files selected for processing (2)
  • rebasebot/bot.py
  • tests/test_rebases.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • rebasebot/bot.py
  • tests/test_rebases.py

Walkthrough

The rebase bot now normalizes GitHub noreply-style bot emails before matching commits, and it preserves the current HEAD commit author when creating the final squashed commit. A new test covers bot emails with numeric prefixes and plus-addressing.

Changes

Bot email normalization and squash flow

Layer / File(s) Summary
Normalization and bot matching
rebasebot/bot.py
Adds _normalize_bot_email, precomputes normalized bot email values, and compares normalized committer emails during bot-commit detection.
Squash author and test coverage
rebasebot/bot.py, tests/test_rebases.py
Captures the HEAD commit author before the soft reset and uses it as the squashed commit author. Adds test_squash_bot_email_normalization to verify normalization and squashing behavior with numeric-prefix bot emails.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error The new info-level log in _do_rebase prints bot email keys (Squashing commits for bot: %s: %s), exposing PII. Remove or redact the email from that log (e.g., log only counts or a hashed identifier) and avoid logging full commit payloads.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: bot email normalization and preserving the squash author.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Weak-Crypto ✅ Passed Touched code only normalizes emails and squashes commits; no weak crypto, custom crypto, or secret/token comparisons were added.
Container-Privileges ✅ Passed The PR only changes bot.py and tests; no container/K8s privilege flags were added, and the existing Dockerfile drops from root to 1001.
No-Hardcoded-Secrets ✅ Passed No API keys, tokens, passwords, private keys, embedded-credential URLs, or long base64 literals were introduced in the touched files.
No-Injection-Vectors ✅ Passed The PR adds only Git email normalization and GitPython commit calls; no eval/exec, shell=True, yaml.load, pickle.loads, os.system, or innerHTML injection patterns appear.
Ai-Attribution ✅ Passed HEAD commit includes Assisted-by: Cursor <cursoragent@cursor.com> and no Co-Authored-By AI trailer was found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Handle GitHub noreply prefixes without collapsing real plus-addressed emails, and keep the squashed bot commit author intact after rewriting history.

Assisted-by: Cursor <cursoragent@cursor.com>
@RadekManak RadekManak force-pushed the feature-rebasebot-bot-emails branch from 07b41e3 to a68b86c Compare June 25, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant