@@ -77,6 +77,10 @@ def to_markdown(text):
77
77
78
78
79
79
def merge_pages ():
80
+ if get_branch () != 'master' :
81
+ print 'ERROR: Not on master'
82
+ return 1
83
+
80
84
git = subprocess .Popen (['git' , 'status' ], stdout = subprocess .PIPE )
81
85
result = git .communicate ()[0 ].strip ().split ('\n ' )
82
86
if not result [- 1 ].startswith ('nothing to commit' ):
@@ -95,16 +99,14 @@ def merge_pages():
95
99
shutil .copyfile ('html/index.html' , 'build/index.html' )
96
100
print 'Files copied sucessfully'
97
101
98
- print 'Switching to gh-pages...'
99
102
git = subprocess .Popen (['git' , 'checkout' , 'gh-pages' ],
100
103
stdout = subprocess .PIPE )
101
104
102
- git = subprocess .Popen (['git' , 'branch' ], stdout = subprocess .PIPE )
103
- print git .communicate ()
104
- return 1
105
- status = merge_git ()
105
+ if get_branch () != 'gh-pages' :
106
+ print 'ERROR: Failed to switch to gh-pages'
107
+ return 1
106
108
107
- print 'Returning to master...'
109
+ status = merge_git ()
108
110
git = subprocess .Popen (['git' , 'checkout' , 'master' ],
109
111
stdout = subprocess .PIPE )
110
112
@@ -149,6 +151,14 @@ def merge():
149
151
else :
150
152
print 'Merge successful'
151
153
154
+ def get_branch ():
155
+ git = subprocess .Popen (['git' , 'branch' ], stdout = subprocess .PIPE )
156
+ branches = git .communicate ()[0 ].strip ().split ('\n ' )
157
+ for i in branches :
158
+ if i .startswith ('*' ):
159
+ return i [1 :].strip ()
160
+
161
+ return None
152
162
153
163
if __name__ == '__main__' :
154
164
if len (sys .argv ) > 1 :
0 commit comments