-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.py
46 lines (41 loc) · 926 Bytes
/
push.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
#!/usr/bin/env python
import sys
import re
import os
import shutil
import commands
import subprocess
def main():
"""
args = sys.argv[1:]
if not args:
print "usage: push.py";
sys.exit(1)
"""
cmd = 'git branch'
(status, branch) = commands.getstatusoutput(cmd)
if status:
sys.stderr.write(branch)
sys.exit(1)
cmd = 'git branch -r'
(status, branch_r) = commands.getstatusoutput(cmd)
if status:
sys.stderr.write(branch_r)
sys.exit(1)
#search keyword
match = re.search('\*\s(\w*)',branch)
if match:
branch = match.group(1)
while 1:
match = re.search('->\s(\w+)([\w\W]*)$',branch_r)
if match:
fdc = match.group(1)
branch_r = match.group(2)
else :
break
#start git push
cmd = 'git push '+fdc+' '+branch+':refs/for'+branch_r
print cmd
os.system(cmd)
if __name__ == "__main__":
main()