@@ -114,9 +114,9 @@ def operate(self, operation: str, args: List[str]) -> None:
114
114
assert len (args ) == 1
115
115
parent = args [0 ]
116
116
self .track_current_branch (parent )
117
- elif operation in {"su" , "submit " }:
117
+ elif operation in {"pr " }:
118
118
assert len (args ) == 0
119
- self .submit_stack ()
119
+ self .create_prs ()
120
120
elif operation in {"s" , "sync" }:
121
121
assert len (args ) == 0
122
122
self .sync ()
@@ -134,8 +134,9 @@ def print_stack(self):
134
134
)
135
135
)
136
136
137
- def submit_stack (self ):
137
+ def create_prs (self ):
138
138
"""Submit the stack starting at the current branch going down"""
139
+ branch = self .original_branch
139
140
while branch != self .trunk :
140
141
p = subprocess .run (
141
142
[
@@ -152,7 +153,13 @@ def submit_stack(self):
152
153
)
153
154
has_pr = bool (p .stdout .decode ().strip ())
154
155
if has_pr :
155
- pass
156
+ subprocess .run (
157
+ ["git" , "push" ],
158
+ check = True ,
159
+ stdout = sys .stdout .buffer ,
160
+ stderr = sys .stderr .buffer ,
161
+ )
162
+ print (f"Updated PR for { branch } " )
156
163
else :
157
164
parent = self .gitstack [branch ]
158
165
subprocess .run (
@@ -161,9 +168,17 @@ def submit_stack(self):
161
168
stdout = sys .stdout .buffer ,
162
169
stderr = sys .stderr .buffer ,
163
170
)
171
+ print (f"Created PR for { branch } " )
164
172
165
173
branch = self .switch_to_parent ()
166
174
175
+ subprocess .run (
176
+ ["git" , "switch" , self .original_branch ],
177
+ check = True ,
178
+ stdout = sys .stdout .buffer ,
179
+ stderr = sys .stderr .buffer ,
180
+ )
181
+
167
182
def create_branch (self , branch : str , parent ) -> None :
168
183
"""Create new branch and add to gitstack"""
169
184
subprocess .run (
@@ -180,7 +195,7 @@ def track_current_branch(self, parent):
180
195
print (f"Branch { parent } does not exist" )
181
196
return
182
197
183
- branch = git_get_current_branch ()
198
+ branch = self . original_branch
184
199
if branch == parent :
185
200
print ("Branch cannot be its own parent" )
186
201
return
@@ -342,12 +357,12 @@ def _check_and_rebase(self, branch: str) -> None:
342
357
)
343
358
current_base_sha = p .stdout .decode ().strip ()
344
359
if current_parent_sha == current_base_sha :
345
- logger . info (
346
- "Branch %s doesn't need to be rebased on top of %s " , branch , parent
360
+ print (
361
+ f "Branch { branch } up-to-date with { parent } " , branch , parent
347
362
)
348
363
return
349
- logger . info ( "Rebasing %s on top of %s" , branch , parent )
350
- subprocess .run (["git" , "rebase " , parent , branch ], check = True )
364
+ print ( f"Merging { parent } into { branch } " )
365
+ subprocess .run (["git" , "merge " , parent ], check = True )
351
366
352
367
def _get_trunk (self ):
353
368
"""Get name of trunk based on possible candidates"""
0 commit comments