Skip to content

Add GitHub commit URL detection to show commit info instead of repo info#213

Open
mvineetmenon wants to merge 1 commit intojohnmaguire:masterfrom
mvineetmenon:master
Open

Add GitHub commit URL detection to show commit info instead of repo info#213
mvineetmenon wants to merge 1 commit intojohnmaguire:masterfrom
mvineetmenon:master

Conversation

@mvineetmenon
Copy link
Contributor

@mvineetmenon mvineetmenon commented Dec 21, 2025

This change adds support for detecting GitHub commit URLs in the Cardinal IRC bot's GitHub plugin. When a commit URL is posted in a channel, the bot will now display the commit subject and add/delete statistics instead of the repository information.

Changes Made:

  • Added COMMIT_URL_REGEX to match GitHub commit URLs with the pattern https://github.com/user/repo/commit/sha
  • Modified the get_repo_info event handler to check for commit URLs first, prioritizing them over issue/repo URLs
  • Added _show_commit method that fetches commit data from the GitHub API and formats it as sha: subject (+additions -deletions)
  • Updated test suite to include comprehensive tests for commit URL detection and display functionality
  • Removed extraneous tests to keep the implementation focused on the core commit URL feature

The implementation maintains backward compatibility - repo and issue URLs continue to work as before, but commit URLs now get special handling to show more relevant commit-specific information.

Test Plan

  • Added unit tests for COMMIT_URL_REGEX pattern matching with various GitHub URL formats
  • Added integration tests for get_repo_info method with commit URLs, including cases with and without commit stats
  • Added test for issue URL handling to ensure existing functionality remains intact
  • Added test for repo URL fallback behavior
  • All tests use mocked HTTP responses to avoid external API dependencies
  • Tests verify correct message formatting and API call patterns
  • Ran existing test suite to ensure no regressions in other plugin functionality

Contribution Checklist

- Add COMMIT_URL_REGEX to match GitHub commit URLs
- Modify get_repo_info to prioritize commit URLs over repo/issue URLs
- Add _show_commit method to display commit subject and add/delete stats
- Update tests to cover commit URL detection and display functionality
@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.77%. Comparing base (f74b0ec) to head (e7162c2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #213   +/-   ##
=======================================
  Coverage   88.77%   88.77%           
=======================================
  Files           8        8           
  Lines        1042     1042           
=======================================
  Hits          925      925           
  Misses        117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johnmaguire
Copy link
Owner

johnmaguire commented Dec 22, 2025

Hey this looks really great, thank you for this! I will test it out soon and merge it as long as everything is working correctly.

One quick thought - Github often uses this syntax for identifying issues: #213. Perhaps it's worth supporting this format in the .issue command? Totally irrelevant to the current PR, ignore me please.

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.

2 participants