-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathapply_patch.py
More file actions
30 lines (24 loc) · 761 Bytes
/
apply_patch.py
File metadata and controls
30 lines (24 loc) · 761 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
27
28
29
30
from subprocess import call
import sys
patch = sys.argv[1]
parts = patch.split("/")
start = int(parts[0][-1])
print(start)
if parts[1] == "complete":
start += 1
patch_file = parts[2]
skip = False
else:
patch_file = parts[1]
skip = True
to_patch = patch_file.split(".")[0] + ".py"
for session in range(start, 9):
if skip:
skip = False
else:
filename = "session{}/{}".format(session, to_patch)
call("git checkout {}".format(filename), shell=True)
call("patch -p1 {} < {}".format(filename, patch), shell=True)
filename = "session{}/complete/{}".format(session, to_patch)
call("git checkout {}".format(filename), shell=True)
call("patch -p1 {} < {}".format(filename, patch), shell=True)