-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathgpush.py
More file actions
25 lines (20 loc) · 712 Bytes
/
gpush.py
File metadata and controls
25 lines (20 loc) · 712 Bytes
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
#!/usr/bin/env python
# coding=utf-8
from subprocess import Popen,PIPE,STDOUT
from os import system
def gpush():
branchColorRule = readFromShell('git config color.branch')
if ('always' == branchColorRule):
system('git config color.branch auto')
getBranch = "git branch | sed -n '/\* /s///p'"
gitBranch = readFromShell(getBranch)
command = 'git push origin %s'%(gitBranch)
print command
system(command)
if ('always' == branchColorRule):
system('git config color.branch always')
def readFromShell(command):
p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
result = p.stdout.read().strip()
return result
gpush()