forked from cosmicpython/book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-branches.py
executable file
·36 lines (31 loc) · 1.1 KB
/
push-branches.py
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
31
32
33
34
35
36
#!/usr/bin/env python
import subprocess
from pathlib import Path
from chapters import CHAPTERS, NO_EXERCISE, STANDALONE
processes = []
for chapter in CHAPTERS + STANDALONE:
print('pushing', chapter)
processes.append(subprocess.Popen(
['git', 'push', '-v', '--force-with-lease', 'origin', chapter],
cwd=Path(__file__).parent / 'code',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
))
if chapter in NO_EXERCISE:
continue
exercise_branch = f'{chapter}_exercise'
print('pushing', exercise_branch)
processes.append(subprocess.Popen(
['git', 'push', '-v', '--force-with-lease', 'origin', exercise_branch],
cwd=Path(__file__).parent / 'code',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
))
print('pushing master')
processes.append(subprocess.Popen(
['git', 'push', '-v', '--force-with-lease', 'origin', 'master'],
cwd=Path(__file__).parent / 'code',
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
))
for p in processes:
stdout, stderr = p.communicate()
print(stdout)
print(stderr)