##// END OF EJS Templates
api: allow updates and setting description renderer for pull requests via the API.
marcink -
r2904:930fb0cb default
parent child Browse files
Show More
@@ -574,7 +574,8 b' def comment_pull_request('
574 @jsonrpc_method()
574 @jsonrpc_method()
575 def create_pull_request(
575 def create_pull_request(
576 request, apiuser, source_repo, target_repo, source_ref, target_ref,
576 request, apiuser, source_repo, target_repo, source_ref, target_ref,
577 title=Optional(''), description=Optional(''), reviewers=Optional(None)):
577 title=Optional(''), description=Optional(''), description_renderer=Optional(''),
578 reviewers=Optional(None)):
578 """
579 """
579 Creates a new pull request.
580 Creates a new pull request.
580
581
@@ -599,6 +600,10 b' def create_pull_request('
599 :type title: str
600 :type title: str
600 :param description: Set the pull request description.
601 :param description: Set the pull request description.
601 :type description: Optional(str)
602 :type description: Optional(str)
603 :type description_renderer: Optional(str)
604 :param description_renderer: Set pull request renderer for the description.
605 It should be 'rst', 'markdown' or 'plain'. If not give default
606 system renderer will be used
602 :param reviewers: Set the new pull request reviewers list.
607 :param reviewers: Set the new pull request reviewers list.
603 Reviewer defined by review rules will be added automatically to the
608 Reviewer defined by review rules will be added automatically to the
604 defined list.
609 defined list.
@@ -679,7 +684,11 b' def create_pull_request('
679 source_ref=title_source_ref,
684 source_ref=title_source_ref,
680 target=target_repo
685 target=target_repo
681 )
686 )
687 # fetch renderer, if set fallback to plain in case of PR
688 rc_config = SettingsModel().get_all_settings()
689 default_system_renderer = rc_config.get('rhodecode_markup_renderer', 'plain')
682 description = Optional.extract(description)
690 description = Optional.extract(description)
691 description_renderer = Optional.extract(description_renderer) or default_system_renderer
683
692
684 pull_request = PullRequestModel().create(
693 pull_request = PullRequestModel().create(
685 created_by=apiuser.user_id,
694 created_by=apiuser.user_id,
@@ -691,6 +700,7 b' def create_pull_request('
691 reviewers=reviewers,
700 reviewers=reviewers,
692 title=title,
701 title=title,
693 description=description,
702 description=description,
703 description_renderer=description_renderer,
694 reviewer_data=reviewer_rules,
704 reviewer_data=reviewer_rules,
695 auth_user=apiuser
705 auth_user=apiuser
696 )
706 )
@@ -706,8 +716,8 b' def create_pull_request('
706 @jsonrpc_method()
716 @jsonrpc_method()
707 def update_pull_request(
717 def update_pull_request(
708 request, apiuser, pullrequestid, repoid=Optional(None),
718 request, apiuser, pullrequestid, repoid=Optional(None),
709 title=Optional(''), description=Optional(''), reviewers=Optional(None),
719 title=Optional(''), description=Optional(''), description_renderer=Optional(''),
710 update_commits=Optional(None)):
720 reviewers=Optional(None), update_commits=Optional(None)):
711 """
721 """
712 Updates a pull request.
722 Updates a pull request.
713
723
@@ -721,6 +731,9 b' def update_pull_request('
721 :type title: str
731 :type title: str
722 :param description: Update pull request description.
732 :param description: Update pull request description.
723 :type description: Optional(str)
733 :type description: Optional(str)
734 :type description_renderer: Optional(str)
735 :param description_renderer: Update pull request renderer for the description.
736 It should be 'rst', 'markdown' or 'plain'
724 :param reviewers: Update pull request reviewers list with new value.
737 :param reviewers: Update pull request reviewers list with new value.
725 :type reviewers: Optional(list)
738 :type reviewers: Optional(list)
726 Accepts username strings or objects of the format:
739 Accepts username strings or objects of the format:
@@ -803,10 +816,15 b' def update_pull_request('
803
816
804 title = Optional.extract(title)
817 title = Optional.extract(title)
805 description = Optional.extract(description)
818 description = Optional.extract(description)
819 description_renderer = Optional.extract(description_renderer)
820
806 if title or description:
821 if title or description:
807 PullRequestModel().edit(
822 PullRequestModel().edit(
808 pull_request, title or pull_request.title,
823 pull_request,
809 description or pull_request.description, apiuser)
824 title or pull_request.title,
825 description or pull_request.description,
826 description_renderer or pull_request.description_renderer,
827 apiuser)
810 Session().commit()
828 Session().commit()
811
829
812 commit_changes = {"added": [], "common": [], "removed": []}
830 commit_changes = {"added": [], "common": [], "removed": []}
General Comments 0
You need to be logged in to leave comments. Login now