feat: PullRequest DTO with chainable actions#35
Conversation
Added chainable action methods to PullRequest DTO that allow direct manipulation of pull requests without needing the wrapper class. The DTO now accepts optional connector, owner, and repo parameters to enable action methods. Changes: - Modified PullRequest::fromArray() to accept connector, owner, and repo parameters - Added chainable action methods: merge(), close(), reopen(), markDraft(), markReady() - Added review methods: approve(), requestChanges(), comment() - Added label management: addLabel(), addLabels(), removeLabel(), setLabels() - Added reviewer management: requestReviewer(), requestReviewers(), requestTeamReview() - Added assignee management: assign(), assignUser(), unassign() - Added convenience methods: squashMerge(), rebaseMerge() - Comprehensive test coverage with 26 test cases - 100% code coverage - All quality gates pass (PHPStan, Pint) Closes #21
|
Warning Rate limit exceeded@jordanpartridge has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 40 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Summary
Implements issue #21 by adding chainable action methods directly to the PullRequest DTO. The DTO now accepts optional connector, owner, and repo parameters, enabling developers to perform PR operations without needing the wrapper class.
Changes
PullRequest DTO Enhancement
PullRequest::fromArray()to accept optional connector, owner, and repo parametersensureConnectorAvailable()guard method with PHPStan assertionsState Management Methods
merge(string $method, ?string $message, ?string $title)- Merge PR with specified strategysquashMerge(?string $message)- Convenience method for squash mergerebaseMerge()- Convenience method for rebase mergeclose()- Close the pull requestreopen()- Reopen a closed pull requestmarkDraft()- Convert PR to draftmarkReady()- Mark draft PR as ready for reviewReview Methods
approve(?string $body)- Approve the PRrequestChanges(string $body)- Request changes on the PRsubmitReview(string $event, ?string $body, array $comments)- Generic review submissioncomment(string $body)- Add a comment to the PRLabel Management
addLabel(string $label)- Add a single labeladdLabels(array $labels)- Add multiple labelsremoveLabel(string $label)- Remove a labelsetLabels(array $labels)- Replace all labelsReviewer Management
requestReviewer(string $username)- Request a single reviewerrequestReviewers(array $usernames)- Request multiple reviewersrequestTeamReview(string $teamSlug)- Request a team reviewAssignee Management
assignUser(string $username)- Assign a single userassign(array $usernames)- Assign multiple usersunassign(array $usernames)- Unassign usersUsage Example
Test Coverage
Quality Gates
Backward Compatibility
The changes are fully backward compatible:
fromArray()has optional parameters with null defaultsPullRequest::fromArray($data)continues to workCloses #21