-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
73 lines (64 loc) · 2.02 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from tkinter import messagebox
from customtkinter import *
import os, json, datetime
def now():
today = datetime.datetime.now()
month = today.month
day = today.day
year = int(str(today.year)[2:])
hour = today.hour
minute = today.minute
if month < 10:
month = f"0{month}"
if day < 10:
day = f"0{day}"
if year < 10:
year = f"0{year}"
if hour < 10:
hour = f"0{hour}"
if minute < 10:
minute = f"0{minute}"
return f"{month}-{day}-{year} {hour}:{minute}"
def commitment(_dir: str, commit : str):
msg = f"[{commit}]"
if commit == "":
msg = ""
os.system(f"git config --global --add safe.directory {_dir}")
os.system(f"cd {_dir}")
if os.path.exists("setup.json"):
file = open("setup.json", "r")
data = json.loads(file.read())
if data == "Error":
messagebox.showerror("ERROR", "Please add your setup file")
else:
execution = f"git config --global user.name \"{data['name']}\""
os.system(execution)
execution = f"git config --global user.email \"{data['email']}\""
os.system(execution)
execution = "git add -A"
os.system(execution)
execution = f"git commit -m \"{now()} {msg}\" "
os.system(execution)
execution = f"git push origin main"
os.system(execution)
messagebox.showinfo("SUCCESS", "Done")
else:
messagebox.showerror("ERROR", "Please add your setup file")
def start():
base = CTk()
base.title("Easy committer")
base.geometry("500x150")
_d = CTkFrame(base)
CTkLabel(_d, text="Directory:\t", font=("Times New Roman", 25), justify="center").pack(side="left")
directory = CTkEntry(_d, font=("Courier New", 25))
directory.pack(expand=True, side="left", fill="x")
_d.pack(fill='x')
_c = CTkFrame(base)
CTkLabel(_c, text="Commit message:\t", font=("Times New Roman", 25), justify="center").pack(side="left")
commit = CTkEntry(_c, font=("Courier New", 25))
commit.pack(expand=True, side="left", fill="x")
_c.pack(fill='x')
CTkButton(base, text="Commit", command=lambda: commitment(directory.get(), commit.get())).pack(fill="x")
base.mainloop()
if __name__ == "__main__":
start()