-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_request.py
More file actions
26 lines (23 loc) · 775 Bytes
/
pull_request.py
File metadata and controls
26 lines (23 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
import git
import json
def create_pull_request(project_name, repo_name, title, description, head_branch, base_branch, git_token):
"""Creates the pull request for the head_branch against the base_branch"""
git_pulls_api = "https://api.github.com/repos/{0}/{1}/pulls".format(
project_name,
repo_name)
headers = {
"Authorization": "token {0}".format(git_token),
"Content-Type": "application/vnd.github+json"}
payload = {
"title": title,
"body": description,
"head": head_branch,
"base": base_branch,
}
r = requests.post(
git_pulls_api,
headers=headers,
data=json.dumps(payload))
if not r.ok:
print("Request Failed: {0}".format(r.text))