Show More
@@ -19,7 +19,7 b' import sys' | |||
|
19 | 19 | from subprocess import Popen, PIPE, check_call, check_output |
|
20 | 20 | from urllib import urlopen |
|
21 | 21 | |
|
22 | from gh_api import get_pull_request | |
|
22 | from gh_api import get_pull_request, get_pull_request_files | |
|
23 | 23 | |
|
24 | 24 | def find_rejects(root='.'): |
|
25 | 25 | for dirname, dirs, files in os.walk(root): |
@@ -37,7 +37,8 b" def backport_pr(branch, num, project='ipython/ipython'):" | |||
|
37 | 37 | current_branch = get_current_branch() |
|
38 | 38 | if branch != current_branch: |
|
39 | 39 | check_call(['git', 'checkout', branch]) |
|
40 | pr = get_pull_request(project, num) | |
|
40 | pr = get_pull_request(project, num, auth=True) | |
|
41 | files = get_pull_request_files(project, num, auth=True) | |
|
41 | 42 | patch_url = pr['patch_url'] |
|
42 | 43 | title = pr['title'] |
|
43 | 44 | description = pr['body'] |
@@ -65,9 +66,16 b" def backport_pr(branch, num, project='ipython/ipython'):" | |||
|
65 | 66 | |
|
66 | 67 | p = Popen(['git', 'apply'], stdin=PIPE) |
|
67 | 68 | a,b = p.communicate(patch) |
|
69 | ||
|
70 | filenames = [ f['filename'] for f in files ] | |
|
71 | add = Popen(['git', 'add'] + filenames) | |
|
72 | add.wait() | |
|
73 | if add.returncode: | |
|
74 | print("git add %s failed!" % filenames) | |
|
75 | return 1 | |
|
68 | 76 | |
|
69 |
commit = Popen(['git', 'commit', ' |
|
|
70 |
commit. |
|
|
77 | commit = Popen(['git', 'commit', '-m', msg]) | |
|
78 | commit.wait() | |
|
71 | 79 | if commit.returncode: |
|
72 | 80 | print("commit failed!") |
|
73 | 81 | return 1 |
@@ -107,6 +107,15 b' def get_pull_request(project, num, auth=False):' | |||
|
107 | 107 | response.raise_for_status() |
|
108 | 108 | return json.loads(response.text, object_hook=Obj) |
|
109 | 109 | |
|
110 | def get_pull_request_files(project, num, auth=False): | |
|
111 | """get list of files in a pull request""" | |
|
112 | url = "https://api.github.com/repos/{project}/pulls/{num}/files".format(project=project, num=num) | |
|
113 | if auth: | |
|
114 | header = make_auth_header() | |
|
115 | else: | |
|
116 | header = None | |
|
117 | return get_paged_request(url, headers=header) | |
|
118 | ||
|
110 | 119 | element_pat = re.compile(r'<(.+?)>') |
|
111 | 120 | rel_pat = re.compile(r'rel=[\'"](\w+)[\'"]') |
|
112 | 121 |
General Comments 0
You need to be logged in to leave comments.
Login now