I’m currently working on a plugin that will block a merge from occurring based on the build status as well if an automated comment gets posted to the pull request. I currently implement RepositoryMergeCheck and use PreRepositoryHook’s preUpdate method to get the build status whenever a new one is posted. In addition to that I’m using the PullRequestService to get the latest comment that was posted to the pull request.
The issue I’m finding is that there could potentially be a timing issue between when the build status was posted and when the comment was posted. For example if the build status turns out to be OK and then it checks for the latest comment (which still hasn’t been posted) and it can’t find anything it will allow the merge to occur however eventually a comment gets posted which means it should have blocked the merge.
I’ve tried to add an EventListener and that works great to let me know any time a comment is posted but how can I then block the merge from inside the EventListener? The only parameter it takes is PullRequestCommentAddedEvent.
If I could please get some help as to how to solve this timing issue so that I can check whether or not I should block a merge only after both the build status and a potential comment has been posted to a pull request.