1
1
from subprocess import call
2
2
from sys import platform as _platform
3
+ from colors import logcolors
4
+
5
+
3
6
def init ():
4
7
call ('git init' )
5
- # git add <filename>
8
+
9
+
6
10
def createReadme ():
7
11
if _platform == "linux" or _platform == "linux2" :
8
12
call ('touch README.md' )
@@ -12,38 +16,50 @@ def createReadme():
12
16
call ('type nul>README.md' )
13
17
14
18
15
- # Windows
16
19
def add (filelist ):
17
20
for file in filelist :
18
21
# perform git add on file
19
- print ("Adding" , file )
22
+ print (f"{ logcolors .SUCCESS } Adding{ logcolors .ENDC } " ,
23
+ file .split ('\\ ' )[- 1 ])
20
24
call (('git add ' + file ))
21
25
22
26
# git commit -m "passed message"
23
- def commit (filelist ):
27
+
28
+
29
+ def commit (filelist ,* args ,** kwargs ):
30
+ diffarr = kwargs .get ('diffarr' , - 1 )
24
31
for file in filelist :
25
32
# ask user for commit message
26
- msg = str (input ('Enter the commit message for ' + file + ' or enter -r to reject commit' ))
33
+ msg = str (input (f'{ logcolors .BOLD } Enter the commit message for{ logcolors .ENDC } ' +
34
+ file .split ('\\ ' )[- 1 ] + f' { logcolors .BOLD } or enter { logcolors .ERROR } -r{ logcolors .ENDC } to reject commit{ logcolors .ENDC } ' ))
27
35
# if msg == -r reject commit
28
36
if (msg == '-r' ):
37
+ print (f'{ logcolors .ERROR } commit rejected{ logcolors .ENDC } ' )
38
+ if (diffarr != - 1 ):
39
+ diffarr .remove (diffarr [filelist .index (file )])
29
40
filelist .remove (file )
30
- print ('commit rejected' )
31
41
call ('cls' , shell = True )
32
42
return False
33
43
# else execute git commit for the file
34
- #added a comment
44
+ # added a comment
35
45
else :
36
- filelist .remove (file )
37
46
call ('git commit -m "' + msg + '"' )
38
- call ('cls' , shell = True )
39
-
47
+ call ('cls' , shell = True )
48
+ print (
49
+ f'Commited { logcolors .CYAN } { file } { logcolors .ENDC } with msg: { logcolors .BOLD } { msg } { logcolors .ENDC } ' )
50
+
51
+
40
52
def setremote (url ):
41
53
call ('git remote add origin ' + url )
42
-
54
+
55
+
43
56
def setBranch (branch ):
44
57
call ('git branch -M ' + branch )
45
-
58
+
46
59
# git push
47
- def push (url , branch ):
60
+
61
+
62
+ def push (url , branch ):
48
63
call ('git push -u ' + url + ' ' + branch )
49
- #added a comment
64
+ call ('cls' , shell = True )
65
+ print (f'{ logcolors .SUCCESS } Successfully Pushed Changes{ logcolors .ENDC } ' )
0 commit comments