-
Notifications
You must be signed in to change notification settings - Fork 1
/
new-subs-pull.py
executable file
·58 lines (52 loc) · 971 Bytes
/
new-subs-pull.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env -S python3 -u
import sys
import os
import re
import subprocess
import shlex
new_subs_dir = "new-subs"
remote_url = os.environ.get("NEW_SUBS_REPO_URL")
if not os.path.exists(f"{new_subs_dir}/.git"):
os.makedirs(new_subs_dir, exist_ok=True)
args = [
"git",
"-c", "init.defaultBranch=main",
"-C", new_subs_dir,
"init",
]
print(shlex.join(args))
proc = subprocess.run(
args,
check=True,
timeout=10,
)
# TODO check if remote exists
if True:
print("git remote add")
args = [
"git",
"-C", new_subs_dir,
"remote",
"add",
"origin",
remote_url,
]
proc = subprocess.run(
args,
check=True,
timeout=10,
)
print("git pull")
args = [
"git",
"-C", new_subs_dir,
"pull",
"origin",
"main",
"--depth=1",
]
proc = subprocess.run(
args,
check=True,
timeout=10,
)