Skip to content

Conversation

joshuadavidthomas
Copy link
Owner

@joshuadavidthomas joshuadavidthomas commented Jun 19, 2025

closes #15

Copilot

This comment was marked as outdated.

Copy link

@Copilot Copilot AI left a 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):
Copy link
Preview

Copilot AI Jul 25, 2025

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.

@joshuadavidthomas joshuadavidthomas marked this pull request as ready for review July 25, 2025 18:23
@joshuadavidthomas joshuadavidthomas merged commit 01e2bcf into main Jul 25, 2025
21 checks passed
@joshuadavidthomas joshuadavidthomas deleted the gh-command branch July 25, 2025 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for defining command callbacks, for issue/PR comments containing @ the github app
1 participant