Skip to content

Fix Copilot author detection in mergify rules - #155

Merged
Benbentwo merged 1 commit into
mainfrom
Benbentwo/skip-copilot-prs
Feb 25, 2026
Merged

Benbentwo merged 1 commit into
mainfrom
Benbentwo/skip-copilot-prs

Conversation

@Benbentwo

@Benbentwo Benbentwo commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

what

  • Fix case-sensitive regex matching for Copilot-authored PRs in mergify rules
  • Add explicit author=Copilot match for the Copilot coding agent
  • Use (?i) flag for case-insensitive regex matching

why

  • The Copilot coding agent's GitHub login is Copilot (capital C), but the regex .*copilot.* was case-sensitive and didn't match
  • This caused PRs authored by Copilot with no file changes to be incorrectly auto-closed
  • Ensures Copilot-authored PRs are properly exempted from the "close PRs with no changes" rule

references

Summary by CodeRabbit

  • Chores
    • Updated internal pull request automation configuration to refine detection of system-generated contributions.

Make Copilot author matching case-insensitive and add explicit author=Copilot match for the Copilot coding agent. This prevents PRs authored by Copilot with no file changes from being auto-closed.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@Benbentwo
Benbentwo requested review from a team as code owners February 25, 2026 21:53
@coderabbitai

coderabbitai Bot commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated the Mergify configuration to refine how Copilot-authored pull requests are detected. Changed from generic regex patterns to explicit author matching and case-insensitive body pattern checks for more precise identification.

Changes

Cohort / File(s) Summary
Mergify Configuration
.github/mergify.yml
Modified is_copilot_author condition to replace generic author~=.*copilot.* with explicit author=Copilot and updated body pattern matching to use case-insensitive copilot detection. Changes detection logic from regex-based to explicit matching.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested labels

automation

Suggested reviewers

  • osterman

Poem

🐰✨ A clever rabbit hops with glee,
Mergify's eye grows sharp and keen,
Now Copilot's mark is clear to see,
No fuzzy patterns in between!
Configuration's dance, refined and true,
Automation flows anew! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main change: fixing Copilot author detection in Mergify rules through case-insensitive matching and explicit author matching.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Benbentwo/skip-copilot-prs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mergify
mergify Bot requested review from a team February 25, 2026 21:54
@mergify

mergify Bot commented Feb 25, 2026

Copy link
Copy Markdown

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Feb 25, 2026
@Benbentwo
Benbentwo added this pull request to the merge queue Feb 25, 2026
@mergify
mergify Bot requested a review from a team February 25, 2026 21:55
Merged via the queue into main with commit 3ea29af Feb 25, 2026
9 of 10 checks passed
@Benbentwo
Benbentwo deleted the Benbentwo/skip-copilot-prs branch February 25, 2026 21:55
@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Feb 25, 2026

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
.github/mergify.yml (1)

47-49: author~=(?i).*copilot.* supersedes the two explicit author= conditions above it.

Mergify leverages Python regular expressions to match rules, and (?i) is a supported inline modifier in Python regex, so line 49 is syntactically valid. However, since (?i).*copilot.* matches any username that contains "copilot" in any case, it fully subsumes both author=github-copilot[bot] (line 47) and author=Copilot (line 48) — making those two explicit entries redundant within this or block.

Two minor follow-on points worth considering:

  1. Overbreadth: (?i).*copilot.* would also exempt any future account whose login merely contains the word "copilot" (e.g. my-copilot-helper) from the no-changes auto-close rule. If stricter matching is preferred, anchoring the pattern (e.g. (?i)^(github-)?copilot(\[bot\])?$) would limit the exemption to known Copilot identities only.

  2. Redundancy cleanup (optional): If the broad regex is intentional, the two explicit author= lines can be removed for brevity.

♻️ Option A — Keep explicit entries, narrow the fallback regex (preferred)
   is_copilot_author: &is_copilot_author
     or:
       - "author=github-copilot[bot]"
       - "author=Copilot"
-      - "author~=(?i).*copilot.*"
+      - "author~=(?i)^(github-)?copilot(\[bot\])?$"
       - "body~=(?i)Co-authored-by:.*copilot"
♻️ Option B — Remove redundant explicit entries, keep broad regex as-is
   is_copilot_author: &is_copilot_author
     or:
-      - "author=github-copilot[bot]"
-      - "author=Copilot"
       - "author~=(?i).*copilot.*"
       - "body~=(?i)Co-authored-by:.*copilot"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/mergify.yml around lines 47 - 49, The three author entries
("author=github-copilot[bot]", "author=Copilot", and "author~=(?i).*copilot.*")
conflict because the broad regex supersedes the two explicit matches; fix by
either removing the two explicit lines if you intend to keep the broad
exemption, or (preferred) keep the explicit "author=github-copilot[bot]" and
"author=Copilot" lines and replace the broad "author~=(?i).*copilot.*" pattern
with a narrower, case-insensitive anchored regex that only matches the known
Copilot identities (i.e., optionally "github-" prefix, the literal "copilot",
and an optional "[bot]" suffix) so the explicit entries remain meaningful and
future similar usernames aren’t unintentionally exempted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/mergify.yml:
- Around line 47-49: The three author entries ("author=github-copilot[bot]",
"author=Copilot", and "author~=(?i).*copilot.*") conflict because the broad
regex supersedes the two explicit matches; fix by either removing the two
explicit lines if you intend to keep the broad exemption, or (preferred) keep
the explicit "author=github-copilot[bot]" and "author=Copilot" lines and replace
the broad "author~=(?i).*copilot.*" pattern with a narrower, case-insensitive
anchored regex that only matches the known Copilot identities (i.e., optionally
"github-" prefix, the literal "copilot", and an optional "[bot]" suffix) so the
explicit entries remain meaningful and future similar usernames aren’t
unintentionally exempted.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43a3320 and 2d723b5.

📒 Files selected for processing (1)
  • .github/mergify.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants