-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
executable file
·39 lines (30 loc) · 894 Bytes
/
pre-commit
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
#!/usr/bin/env python3
import subprocess
import os
def get_git_root():
try:
git_root = (
subprocess.check_output(["git", "rev-parse", "--show-toplevel"])
.strip()
.decode("utf-8")
)
return git_root
except subprocess.CalledProcessError:
return None
def run_update_script():
try:
result = subprocess.run(["python3", "helper/update_readme.py"], check=True)
if result.returncode == 0:
pass
else:
print(f"Script failed with return code {result.returncode}.")
except subprocess.CalledProcessError as e:
print(f"Script execution failed with error: {e}")
git_root = get_git_root()
if git_root:
os.chdir(git_root)
print(f"Working dir: {git_root}")
else:
print("Not a git repository.")
print("STEP 1 - Updating README.md")
run_update_script()