#19 Add support for changing milestones
Merged 7 years ago by sayanchowdhury. Opened 7 years ago by mbasti.
mbasti/libpagure milestones  into  master

file modified
+23
@@ -439,6 +439,29 @@ 

          if not return_value['message'].startswith("Successfully"):

              raise Exception(return_value['message'])

  

+     def change_issue_milestone(self, issue_id, milestone):

+         """

+         Change the milestone of an issue.

+         :param issue_id: the id of the issue

+         :param milestone: the new milestone for the issue

+             (set None to remove milestone)

+         :return:

+         """

+         if self.username is None:

+             request_url = "{}/api/0/{}/issue/{}/milestone".format(

+                 self.instance, self.repo, issue_id)

+         else:

+             request_url = "{}/api/0/fork/{}/{}/issue/{}/milestone".format(

+                 self.instance, self.username, self.repo, issue_id)

+ 

+         payload = {} if milestone is None else {'milestone': milestone}

+ 

+         return_value = self.__call_api(request_url,

+                                        method='POST', data=payload)

+ 

+         if not return_value['message'].startswith("Successfully"):

+             raise Exception(return_value['message'])

+ 

      def comment_issue(self, issue_id, body):

          """

          Comment to an issue.

Adds method 'change_issue_milestone' that allows to update or remove milestone of an issue

Counterpart of https://pagure.io/pagure/pull-request/2124

we can have the issue_id in the above line itself?

we should check the type of the milestone is str or None.

Looks good to me other than the comments posted

Do you mean
payload = {} if milestone is None else {'milestone': milestone}

or

raising TypeErrror earlier?

rebased

7 years ago

rebased

7 years ago

Pull-Request has been merged by sayanchowdhury

7 years ago
Metadata