-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.py
36 lines (27 loc) · 964 Bytes
/
git.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
import os
import subprocess
import argparse
from docs.upd_deploy import update
def run_git_commands(desc):
try:
# Add all changes
subprocess.run(['git', 'add', '.'], check=True)
# Commit changes
subprocess.run(['git', 'commit', '-m', desc], check=True)
# Push to GitHub
subprocess.run(['git', 'push'], check=True)
print("Changes pushed successfully to GitHub.")
except subprocess.CalledProcessError as e:
print(f"An error occurred while running git commands: {e}")
def main():
parser = argparse.ArgumentParser(description="Script to update and run git commands.")
parser.add_argument("desc", help="Description for the git commit message")
# Argumente parsen
args = parser.parse_args()
curdir = os.getcwd()
os.chdir("docs")
update()
os.chdir(curdir)
run_git_commands(desc=args.desc)
if __name__ == "__main__":
main()