-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: get commit missing details #52
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
WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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. Comment |
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.
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 pull request improves the resilience of the GitHub commit retrieval by replacing exception-based error handling with defensive programming using default values. The getCommit method now gracefully handles missing commit metadata from the GitHub API response instead of throwing exceptions.
Key Changes:
- Removed validation that threw exceptions for missing commit author or message fields
- Applied null coalescing operators throughout to provide sensible defaults for all response fields
- Returns 'Unknown' for missing author names, 'No message' for missing commit messages, and empty strings for optional URL fields
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/VCS/Adapter/Git/GitHub.php (1)
497-509: Consider aligning error handling withgetLatestCommit.The
getCommitmethod now returns defaults for missing fields, whilegetLatestCommit(lines 526-535) throws an exception when required fields are missing. This creates an inconsistency in error handling behavior across similar methods.Consider whether:
- Both methods should fail fast with exceptions for missing critical fields, OR
- Both methods should be resilient and return defaults
The resilient approach (current implementation) is beneficial for edge cases like deleted users or system commits, but callers may prefer to know when data is incomplete rather than receiving default values.
Would you like me to generate a script to verify if there are other methods in the codebase that handle commit data, to ensure consistent error handling across all of them?
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/VCS/Adapter/Git/GitHub.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Agent
🔇 Additional comments (1)
src/VCS/Adapter/Git/GitHub.php (1)
497-509: The field mapping issue has been resolved!The previous critical issue regarding incorrect field mapping for
avatar_urlandhtml_urlhas been fixed. The code now correctly:
- Retrieves the GitHub user object from
$body['author'](line 498)- Uses this for
commitAuthorAvatarandcommitAuthorUrl(lines 505-506)- Retrieves the Git commit author from
$commit['author'](line 500)- Uses this for
commitAuthorname (line 503)This aligns with the GitHub API structure where
response.body.authorcontains the GitHub user fields (avatar_url,html_url) andresponse.body.commit.authorcontains the Git commit author fields (name,date).
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.