#38 add create_pr function
Merged 5 years ago by cverna. Opened 5 years ago by lenkaseg.
lenkaseg/libpagure PR_create  into  master

file modified
+28
@@ -571,6 +571,34 @@ 

  

          return return_value["activities"]

  

+     def create_pull_request(self, title, branch_to, branch_from,

+             initial_comment=None):

+         """

+         Create pull-request

+          -------------------

+         Open a new pull-request from this project to itself or its parent (if

+         this project is a fork).

+         :param title: the title to give the pull-request

+         :param branch_to: the name of the branch the submitted changes should

+             be merged into

+         :param branch_from: the name of the branch containing the changes to merge

+         :param initial_comment: the initial comment describing what these changes

+             are about

+         :return:

+         """

+         request_url = "{}pull-request/new".format(self.create_basic_url())

+         payload = {

+             "title": title,

+             "branch_to": branch_to,

+             "branch_from": branch_from,

+         }

+         if initial_comment is not None:

+             payload["initial_comment"] = initial_comment

+ 

+         return_value = self._call_api(request_url, method="POST", data=payload)

+ 

+         return return_value

+ 

      def list_pull_requests(self, username, page, status=None):

          """

          List pull-requests filed by user.

Adding a function to create a pull request.

Signed-off-by: Lenka Segura lenka@sepu.cz

Format this dictionary like this

        payload = {
            "title": title,
            "branch_to": branch_to,
            "branch_from": branch_from,
        }

LGTM other than that one minor fix.

rebased onto adb0b0e

5 years ago

rebased onto 661db4c

5 years ago

Done.
I also removed the forgotten 'repo' from the parameters.

I think repo needs to be removed from the doc too :-)

rebased onto 6bb72ca

5 years ago

Pull-Request has been merged by cverna

5 years ago
Metadata