PullRequest.rst
1 PullRequest 2 =========== 3 4 Create a new Pull Request 5 ------------------------- 6 7 .. code-block:: python 8 9 >>> repo = g.get_repo("PyGithub/PyGithub") 10 >>> body = ''' 11 >>> SUMMARY 12 >>> Change HTTP library used to send requests 13 >>> 14 >>> TESTS 15 >>> - [x] Send 'GET' request 16 >>> - [x] Send 'POST' request with/without body 17 >>> ''' 18 >>> pr = repo.create_pull(title="Use 'requests' instead of 'httplib'", body=body, head="develop", base="master") 19 >>> pr 20 PullRequest(title="Use 'requests' instead of 'httplib'", number=664) 21 22 Get Pull Request by Number 23 --------------------------- 24 25 .. code-block:: python 26 27 >>> repo = g.get_repo("PyGithub/PyGithub") 28 >>> pr = repo.get_pull(664) 29 >>> pr 30 PullRequest(title="Use 'requests' instead of 'httplib'", number=664) 31 32 Get Pull Requests by Query 33 -------------------------- 34 35 .. code-block:: python 36 37 >>> repo = g.get_repo("PyGithub/PyGithub") 38 >>> pulls = repo.get_pulls(state='open', sort='created', base='master') 39 >>> for pr in pulls: 40 ... print(pr.number) 41 ... 42 400 43 861 44 875 45 876 46 47 Add and modify Pull Request comment 48 ----------------------------------- 49 50 .. code-block:: python 51 52 >>> repo = g.get_repo("PyGithub/PyGithub") 53 >>> pr = repo.get_pull(2390) 54 >>> last_commit = pr.get_commits()[pr.commits - 1] 55 >>> comment = pr.create_comment("This is a comment", last_commit, "file.txt", 0) 56 >>> comment 57 PullRequestComment(user=NamedUser(login="anonymous"), id=1057297855) 58 >>> comment.body 59 'This is a comment' 60 >>> comment.edit("This is a modified comment") 61 >>> comment.body 62 'This is a modified comment'