forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcommands.py
More file actions
49 lines (43 loc) · 1.34 KB
/
gitcommands.py
File metadata and controls
49 lines (43 loc) · 1.34 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
from subprocess import call
from sys import platform as _platform
def init():
call('git init')
# git add <filename>
def createReadme():
if _platform == "linux" or _platform == "linux2":
call('touch README.md')
elif _platform == "darwin":
call('touch README.md')
elif _platform == "win32":
call('type nul>README.md')
# Windows
def add(filelist):
for file in filelist:
# perform git add on file
print("Adding" , file)
call(('git add ' + file))
# git commit -m "passed message"
def commit(filelist):
for file in filelist:
# ask user for commit message
msg = str(input('Enter the commit message for ' + file + ' or enter -r to reject commit'))
# if msg == -r reject commit
if(msg == '-r'):
filelist.remove(file)
print('commit rejected')
call('cls', shell=True)
return False
# else execute git commit for the file
#added a comment
else:
filelist.remove(file)
call('git commit -m "' + msg + '"')
call('cls' , shell=True)
def setremote(url):
call('git remote add origin ' + url)
def setBranch(branch):
call('git branch -M ' + branch)
# git push
def push(url , branch):
call('git push -u ' + url + ' ' + branch)
#added a comment