-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
48 lines (42 loc) · 1.18 KB
/
update.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
#!/usr/bin/env python
import os
import sys
try:
from colorama import Fore
except ImportError:
print 'No colorama module found.'
sys.exit()
q = ''
COMMITMSG = 'updates'
if len(sys.argv)==1:
print '''add files to update as arguments
for example
python update.py filex file-y'''
else:
# git add part
for i in enumerate(sys.argv):
if i[0]==0:
continue
command = 'git add '+i[1]
while len(q)==0:
q = raw_input(Fore.GREEN + 'should i \''+command+'\'? (y/n): ' + Fore.RESET)
if q=='y' or q=='Y':
os.system(command)
print '\n'
q = ''
# git commit part
while len(q)==0:
q = raw_input('should i \'git commit -m '+COMMITMSG+'\'? (y/n): ')
if q=='y' or q=='Y':
q = raw_input('you can edit commit message (\'updates\' as default): ')
if q=='':
os.system('git commit -m \''+COMMITMSG+'\'')
print '\n'
else:
os.system('git commit -m \''+q+'\'')
print '\n'
# git push part
while len(q)==0:
q = raw_input('should i \'git push\'? (y/n): ')
if q=='y' or q=='Y':
os.system('git push')