This repository has been archived by the owner on Dec 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Git-Repos-Init.py
110 lines (83 loc) · 2.96 KB
/
Git-Repos-Init.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import os
import subprocess
#OS selection
def os_select():
os.system("clear")
print("\t\t\t\t OS SELECTION \n")
print("Supported OS: \n 1.Windows \n 2.Linux-Debian \n")
os_name = int(input("Enter the choice: "))
return os_name
#data input
prj_path = str(input("\nFile path: "))
prj_name = str(input("Project Name: "))
file_statement = "mkdir " + prj_path + prj_name
init_statement = "cd " + prj_path + prj_name + " && git init"
print("Are you going to push this to Github? (Y|N): ")
opt = str(input())
str.lower(opt)
if opt == 'y':
push_code = str(input("PUSH CODE: "))
repos = str(input("Remote Repos Name: "))
selection = os_select()
elif opt =='n':
selection = os_select()
else:
os.system("clear")
print("ERORR")
#Git Push
def push(statement):
os.system("cd "+prj_path + prj_name + " && git remote add " +repos+" " + statement + " && git push -u "+repos+ " master")
#process
if selection == 1:
print("windows")
elif selection == 2:
#folder create
os.system(file_statement)
print("folder created\n")
#git initialise
os.system(init_statement)
#file create
c_opt = str(input("Do you want to create a file (Y|N): "))
if str.lower(c_opt) == 'y':
while c_opt =='y':
os.system("clear")
file_name = str(input("File name: "))
os.system("touch " + prj_path + prj_name +"/" + file_name) #create a empty file
c_opt = str(input("\n Do you want to create one more file? (Y|N): "))
e = 'y'
git_status = "clear" + "&& cd " + prj_path + prj_name +"&& git status"
git_commit = "cd " + prj_path + prj_name +" && git commit "+ file_name +" -m "
git_log = "cd " + prj_path +prj_name +" && git log"
os.system(git_status) # list the files
while e == 'y':
info = str(input("Enter the file name to add: "))
os.system("cd " + prj_path + prj_name + "&& git add " + info)
e = str(input("Do u want to add one more file (Y|N): "))
#Push to remote
if opt == 'y':
os.system("clear")
os.system(git_status)
print("Project has been created and files as beed added")
#git commit
commit_msg = input("Enter the commit mssg: ")
os.system(git_commit +'"'+commit_msg +'"')
print(git_commit +'"'+commit_msg +'"')
os.system(git_status)
os.system(git_log)
print("\n\n Pushing the repos\n\n")
push(push_code)
elif opt =='n':
os.system("clear")
os.system(git_status)
print("Project has been created and files as beed added")
o = input("Do you want to commit it now(Y|N): ")
str.lower(o)
#git commit
if o == 'y':
commit_msg = input("Enter the commit mssg: ")
os.system(git_commit +'"'+commit_msg +'"')
print(git_commit +'"'+commit_msg +'"')
os.system(git_status)
os.system(git_log)
else:
print("Error")