-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.py
More file actions
61 lines (55 loc) · 2.64 KB
/
tool.py
File metadata and controls
61 lines (55 loc) · 2.64 KB
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
import os
import platform
from dataclasses import dataclass
import subprocess
import argparse
from data import data
@dataclass
class tool:
def clear_screen():
if platform.system() == "Windows":
os.system('cls')
else:
os.system('clear')
def args():
parameter = argparse.ArgumentParser(prog="git_script")
parameter.add_argument('--push', action='store_true', help='Executa o push no repositório')
parameter.add_argument('--pull', action='store_true', help="Ultila O Pull para siconizar o code atual com o do Git Hub")
return parameter.parse_args()
def gitInit(data:data) -> bool:
path = os.path.join(data.path_local)
if not path:return False
try:
subprocess.run(["git","init"])
subprocess.run(["git", "branch", "-M", "main"], check=True)
#git pull origin main --allow-unrelated-histories
subprocess.run(["git","pull","origin","main","--allow-unrelated-histories"]) #remove o commit que nao foi puchado
subprocess.run(["git", "remote", "add", "origin", data.remote_link], check=True) #Adiciona A coneçao remote novamente
subprocess.run(["git","pull","origin","main","--allow-unrelated-histories"]) #remove o commit que nao foi puchados
subprocess.run(["git", "add", "."], check=True)
subprocess.run(["git", "commit", "-m", data.commit], check=True)
subprocess.run(["git", "push", "-u", "origin", "main"], check=True)
subprocess.run(["git","branch","dev"])
except Exception as E:
print(f"Erro Al Execultar Script De git, Erro: {E}")
return False
def gitPush(data:data):
path = os.path.join(data.path_local)
if not path:return False
try:
subprocess.run(["git","pull","origin","main","--allow-unrelated-histories"]) #remove o commit que nao foi puchado
subprocess.run(["git", "branch", "-M", "main"], check=True)
subprocess.run(["git", "add", "."], check=True)
subprocess.run(["git", "commit", "-m", data.commit], check=True)
subprocess.run(["git", "push", "-u", "origin", data.branch], check=True)
except Exception as E:
print(f"Erro Al Execultar Script De git, Erro: {E}")
return False
def gitPull():
path = os.path.join(data.path_local)
if not path:return False
try:
subprocess.run(["git","pull","origin","main"])
except Exception as E:
print(f"Erro Al Execultar Script De git, Erro: {E}")
return False