##// END OF EJS Templates
api/pull-requests: trigger events for comments/review status changes.
marcink -
r3399:820d474e default
parent child Browse files
Show More
@@ -566,6 +566,7 b' def comment_pull_request('
566 566 )
567 567
568 568 if allowed_to_change_status and status:
569 old_calculated_status = pull_request.calculated_review_status()
569 570 ChangesetStatusModel().set_status(
570 571 pull_request.target_repo.repo_id,
571 572 status,
@@ -576,6 +577,20 b' def comment_pull_request('
576 577 Session().flush()
577 578
578 579 Session().commit()
580
581 PullRequestModel().trigger_pull_request_hook(
582 pull_request, apiuser, 'comment',
583 data={'comment': comment})
584
585 if allowed_to_change_status and status:
586 # we now calculate the status of pull request, and based on that
587 # calculation we set the commits status
588 calculated_status = pull_request.calculated_review_status()
589 if old_calculated_status != calculated_status:
590 PullRequestModel().trigger_pull_request_hook(
591 pull_request, apiuser, 'review_status_change',
592 data={'status': calculated_status})
593
579 594 data = {
580 595 'pull_request_id': pull_request.pull_request_id,
581 596 'comment_id': comment.comment_id if comment else None,
@@ -857,6 +872,7 b' def update_pull_request('
857 872
858 873 reviewers_changes = {"added": [], "removed": []}
859 874 if reviewers:
875 old_calculated_status = pull_request.calculated_review_status()
860 876 added_reviewers, removed_reviewers = \
861 877 PullRequestModel().update_reviewers(pull_request, reviewers, apiuser)
862 878
@@ -866,6 +882,13 b' def update_pull_request('
866 882 [get_user_or_error(n).username for n in removed_reviewers])
867 883 Session().commit()
868 884
885 # trigger status changed if change in reviewers changes the status
886 calculated_status = pull_request.calculated_review_status()
887 if old_calculated_status != calculated_status:
888 PullRequestModel().trigger_pull_request_hook(
889 pull_request, apiuser, 'review_status_change',
890 data={'status': calculated_status})
891
869 892 data = {
870 893 'msg': 'Updated pull request `{}`'.format(
871 894 pull_request.pull_request_id),
@@ -44,6 +44,9 b' from rhodecode.events import ('
44 44 ])
45 45 def test_pullrequest_events_serialized(EventClass, pr_util, config_stub):
46 46 pr = pr_util.create_pull_request()
47 if EventClass == PullRequestReviewEvent:
48 event = EventClass(pr, 'approved')
49 else:
47 50 event = EventClass(pr)
48 51 data = event.as_dict()
49 52 assert data['name'] == EventClass.name
General Comments 0
You need to be logged in to leave comments. Login now