From 6bb72ca12922fc14b00dd301e80a9ea4551a0cae Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Feb 28 2019 11:39:28 +0000 Subject: add create_pr function Signed-off-by: Lenka Segura --- diff --git a/libpagure/libpagure.py b/libpagure/libpagure.py index 4d60341..19d3088 100644 --- a/libpagure/libpagure.py +++ b/libpagure/libpagure.py @@ -571,6 +571,34 @@ class Pagure(object): 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.