-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add mention decorator for GitHub command handling #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f258928
to
aac1884
Compare
Updates the kwarg passed to mention handlers from "mention" to "context" to better reflect that it contains a MentionContext object with comment, triggered_by, and scope fields. Also removes unused _mention_permission attribute from MentionHandlerBase protocol. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
for more information, see https://pre-commit.ci
fca9488
to
d396bd7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new mention decorator for handling GitHub event routing based on @-mentions in comments. The decorator allows filtering handlers by username patterns and event scopes (issues, PRs, or commits).
- Adds comprehensive mention extraction and parsing functionality with ReDoS protection
- Introduces a new
@router.mention()
decorator that automatically triggers handlers when users are mentioned - Provides extensive test coverage for the mention system across different event types and scenarios
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/django_github_app/mentions.py |
New module implementing mention extraction, parsing, and scope detection |
src/django_github_app/routing.py |
Extended GitHubRouter with mention decorator functionality |
tests/test_mentions.py |
Comprehensive test suite for mention functionality |
tests/test_routing.py |
Tests for the mention decorator integration |
tests/conftest.py |
Enhanced test fixtures with async mock support |
tests/test_models.py |
Fixed fixture usage in async test |
tests/settings.py |
Added timezone configuration |
Comments suppressed due to low confidence (1)
tests/test_routing.py:158
- The test case uses a regex pattern that matches usernames ending with '-bot', but the expected count is 2 while the comment contains '@deploy-bot', '@Test-bot', and '@user'. The '@user' should not match the pattern, so the count should be correct, but this test doesn't verify that '@user' is actually excluded - only that the total count is 2.
(re.compile(r".*-bot"), "@deploy-bot start @test-bot check @user help", 2),
mentions = list(Mention.from_event(event, username=username, scope=scope)) | ||
|
||
assert len(mentions) == expected_count | ||
for mention, expected in zip(mentions, expected_mentions, strict=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using strict=False
in the zip operation could mask bugs where the lengths of mentions
and expected_mentions
don't match. Since the test already asserts len(mentions) == expected_count
on line 680, using strict=True
would be safer to catch any inconsistencies.
Copilot uses AI. Check for mistakes.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
closes #15