-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.py
38 lines (26 loc) · 882 Bytes
/
task.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
import subprocess
from typing import List
from pathlib import Path
def run_command(cmd: List[str], check: bool = True):
out = subprocess.run(cmd, stdout=subprocess.PIPE, check=check)
print(out.stdout.decode('utf-8'))
def initialize_git():
git_dir = Path(".git")
if not git_dir.exists():
run_command(["git", "init"])
run_command(["git", "add", "--all"])
run_command(["git", "commit", "-am", "Initial commit"])
def update_venv():
venv_dir = Path(".venv")
if not venv_dir.exists():
run_command(["pdm", "venv", "create"])
run_command(["pdm", "use", "--venv", "in-project"])
run_command(["pdm", "install"], check=False)
def update_commit_hooks():
run_command([".venv/bin/pre-commit", "install"])
def main():
initialize_git()
update_venv()
update_commit_hooks()
if __name__ == "__main__":
main()