##// END OF EJS Templates
api/pull-requests: trigger events for comments/review status changes.
marcink -
r3416:ab643e3c stable
parent child Browse files
Show More
@@ -553,6 +553,7 b' def comment_pull_request('
553 553 )
554 554
555 555 if allowed_to_change_status and status:
556 old_calculated_status = pull_request.calculated_review_status()
556 557 ChangesetStatusModel().set_status(
557 558 pull_request.target_repo.repo_id,
558 559 status,
@@ -563,6 +564,20 b' def comment_pull_request('
563 564 Session().flush()
564 565
565 566 Session().commit()
567
568 PullRequestModel().trigger_pull_request_hook(
569 pull_request, apiuser, 'comment',
570 data={'comment': comment})
571
572 if allowed_to_change_status and status:
573 # we now calculate the status of pull request, and based on that
574 # calculation we set the commits status
575 calculated_status = pull_request.calculated_review_status()
576 if old_calculated_status != calculated_status:
577 PullRequestModel().trigger_pull_request_hook(
578 pull_request, apiuser, 'review_status_change',
579 data={'status': calculated_status})
580
566 581 data = {
567 582 'pull_request_id': pull_request.pull_request_id,
568 583 'comment_id': comment.comment_id if comment else None,
@@ -837,6 +852,7 b' def update_pull_request('
837 852
838 853 reviewers_changes = {"added": [], "removed": []}
839 854 if reviewers:
855 old_calculated_status = pull_request.calculated_review_status()
840 856 added_reviewers, removed_reviewers = \
841 857 PullRequestModel().update_reviewers(pull_request, reviewers, apiuser)
842 858
@@ -846,6 +862,13 b' def update_pull_request('
846 862 [get_user_or_error(n).username for n in removed_reviewers])
847 863 Session().commit()
848 864
865 # trigger status changed if change in reviewers changes the status
866 calculated_status = pull_request.calculated_review_status()
867 if old_calculated_status != calculated_status:
868 PullRequestModel().trigger_pull_request_hook(
869 pull_request, apiuser, 'review_status_change',
870 data={'status': calculated_status})
871
849 872 data = {
850 873 'msg': 'Updated pull request `{}`'.format(
851 874 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