##// 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 574 @jsonrpc_method()
575 575 def create_pull_request(
576 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 580 Creates a new pull request.
580 581
@@ -599,6 +600,10 b' def create_pull_request('
599 600 :type title: str
600 601 :param description: Set the pull request description.
601 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 607 :param reviewers: Set the new pull request reviewers list.
603 608 Reviewer defined by review rules will be added automatically to the
604 609 defined list.
@@ -679,7 +684,11 b' def create_pull_request('
679 684 source_ref=title_source_ref,
680 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 690 description = Optional.extract(description)
691 description_renderer = Optional.extract(description_renderer) or default_system_renderer
683 692
684 693 pull_request = PullRequestModel().create(
685 694 created_by=apiuser.user_id,
@@ -691,6 +700,7 b' def create_pull_request('
691 700 reviewers=reviewers,
692 701 title=title,
693 702 description=description,
703 description_renderer=description_renderer,
694 704 reviewer_data=reviewer_rules,
695 705 auth_user=apiuser
696 706 )
@@ -706,8 +716,8 b' def create_pull_request('
706 716 @jsonrpc_method()
707 717 def update_pull_request(
708 718 request, apiuser, pullrequestid, repoid=Optional(None),
709 title=Optional(''), description=Optional(''), reviewers=Optional(None),
710 update_commits=Optional(None)):
719 title=Optional(''), description=Optional(''), description_renderer=Optional(''),
720 reviewers=Optional(None), update_commits=Optional(None)):
711 721 """
712 722 Updates a pull request.
713 723
@@ -721,6 +731,9 b' def update_pull_request('
721 731 :type title: str
722 732 :param description: Update pull request description.
723 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 737 :param reviewers: Update pull request reviewers list with new value.
725 738 :type reviewers: Optional(list)
726 739 Accepts username strings or objects of the format:
@@ -803,10 +816,15 b' def update_pull_request('
803 816
804 817 title = Optional.extract(title)
805 818 description = Optional.extract(description)
819 description_renderer = Optional.extract(description_renderer)
820
806 821 if title or description:
807 822 PullRequestModel().edit(
808 pull_request, title or pull_request.title,
809 description or pull_request.description, apiuser)
823 pull_request,
824 title or pull_request.title,
825 description or pull_request.description,
826 description_renderer or pull_request.description_renderer,
827 apiuser)
810 828 Session().commit()
811 829
812 830 commit_changes = {"added": [], "common": [], "removed": []}
General Comments 0
You need to be logged in to leave comments. Login now