-
Notifications
You must be signed in to change notification settings - Fork 45
Block PR approval when merge conflicts are present #637
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
Prevent PR approval when merge conflicts are detected in the database, even if GitHub returns Unknown or Clean/Mergeable state. This ensures that merge conflict information is preserved and blocks approval appropriately. Changes: - Add check in check_pr_approval_validity to block approval when DB has HasConflicts - Preserve HasConflicts state in set_pr_mergeability_based_on_user_action when GitHub returns Unknown or Clean/Mergeable - Reload PR from DB after mergeability update to ensure latest state is used - Add tests for merge conflict blocking scenarios
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.
Thank you, looks great! Mergeability checking is very tricky, and I just finished a big reworking of it, so some of the invariants might not be documented properly yet, but this PR shouldn't need to change how it works - it should be enough to simply block approvals if the PR is currently unmergeable on GitHub.
- Block approval only based on GitHub mergeable state (HasConflicts), do not use DB mergeability for approval checks. - Restore original behavior of set_pr_mergeability_based_on_user_action and avoid extra DB reload in handle_comment. - Update tests so DB-only conflict scenarios expect approval, matching the desired invariants.
Kobzol
left a 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.
Yeah I think that you did a bit too much there! 😅 I think that the approve_pr_with_merge_conflict_dirty test is enough, otherwise LGTM.
Keep only approve_pr_with_merge_conflict_dirty test as requested by reviewer. Remove tests that modify DB directly (approve_pr_with_merge_conflict_blocked, approve_pr_with_merge_conflict_in_db, approve_pr_with_merge_conflict_clean_but_db_has_conflicts) to avoid 'cheating' and maintain end-to-end test approach.
Kobzol
left a 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.
Thank you! :)
|
no problem! it was nice to work together! ping me if there's some difficulty that i could help. of course i will discover some issues by myself, tho i'm near my pc all the time :3 |
added new func + test
fixes #452
Prevents
r+command from approving PRs with merge conflicts by adding conflict checks incheck_pr_approval_validity(). The implementation usesMergeableState::from()to convert GitHub mergeable state and checks both GitHub and database states to catch conflicts even when GitHub state hasn't been refreshed yet. Returnsapprove_merge_conflict_comment()error message instead of approving the PR.added tests for all conflict scenarios: dirty, blocked, unknown state with DB conflicts, and clean state with DB conflicts.