@@ -103,10 +103,6 @@ def run_updater(branch, element):
103103 stderr = subprocess .DEVNULL ,
104104 check = False ,
105105 )
106- # It fails due to too many random tracking errors
107- # that aren't handled upstream. But it can still create
108- # branches with updates as it goes which are useful
109- return True
110106
111107
112108def create_branch (base_branch ):
@@ -136,11 +132,10 @@ def reformat_commit_message(commit_message):
136132
137133
138134def cherry_pick_top_commit (branches , new_branch ):
139- all_successful = True
140135 for branch in branches :
141136 checkout_branch (branch )
142137 result = subprocess .run (
143- ["git" , "log" , "--format=%H " , "-n" , "1 " ],
138+ ["git" , "rev-parse " , "HEAD " ],
144139 stdout = subprocess .PIPE ,
145140 stderr = subprocess .PIPE ,
146141 check = False ,
@@ -170,9 +165,6 @@ def cherry_pick_top_commit(branches, new_branch):
170165 stdout = subprocess .PIPE ,
171166 stderr = subprocess .PIPE ,
172167 )
173- else :
174- all_successful = False
175- return all_successful
176168
177169
178170def checkout_branch (branch ):
@@ -205,10 +197,7 @@ def cleanup(branches, base_branch, branch_regex):
205197 checkout_branch (base_branch )
206198 clean_branches = [branch for branch in branches if re .match (branch_regex , branch )]
207199 for branch in clean_branches :
208- if not delete_branch (branch ):
209- logging .error (f"Failed to delete local branch: { branch } " )
210- return False
211- return True
200+ delete_branch (branch )
212201
213202
214203def main ():
@@ -234,41 +223,41 @@ def main():
234223 )
235224 args = parser .parse_args ()
236225
237- branch_regex = rf"^update/(components|include|abi|bootstrap|extensions)_.*[.](bst|yml)-diff_md5-.*-for-( { args .base_branch } ) $"
226+ branch_regex = rf"^update/(components|include|abi|bootstrap|extensions)_.*[.](bst|yml)-diff_md5-.*-for-{ args .base_branch } $"
238227
239228 if not validate_environment (args .element , args .base_branch ):
240229 return 1
241230
242- branches = get_local_branches ()
243- if not branches :
231+ if not get_local_branches ():
244232 logging .error ("No branches found" )
245233 return 1
246234
247- if not args .no_cleanup and not cleanup (branches , args .base_branch , branch_regex ):
248- return 1
249-
250- if run_updater (args .base_branch , args .element ):
251- if not is_dirty ():
252- new_branch = create_branch (args .base_branch )
253- if new_branch :
254- new_branches = [
255- branch for branch in branches if re .match (branch_regex , branch )
256- ]
257- if not cherry_pick_top_commit (new_branches , new_branch ):
258- logging .error ("Failed to cherry-pick commit" )
259- return 1
260- else :
261- logging .error ("Failed to create new branch" )
262- return 1
235+ if not args .no_cleanup :
236+ cleanup (get_local_branches (), args .base_branch , branch_regex )
237+
238+ run_updater (args .base_branch , args .element )
239+
240+ if not is_dirty ():
241+ new_branch = create_branch (args .base_branch )
242+ if new_branch :
243+ new_branches = [
244+ branch
245+ for branch in get_local_branches ()
246+ if re .match (branch_regex , branch )
247+ ]
248+ cherry_pick_top_commit (new_branches , new_branch )
249+ if not args .no_cleanup :
250+ cleanup (new_branches , args .base_branch , branch_regex )
251+ checkout_branch (new_branch )
263252 else :
264- logging .error (
265- "The repository is dirty after running auto_updater"
266- if is_dirty ()
267- else "Failed to checkout new branch"
268- )
253+ logging .error ("Failed to create new branch" )
269254 return 1
270255 else :
271- logging .error ("auto_updater failed" )
256+ logging .error (
257+ "The repository is dirty after running auto_updater"
258+ if is_dirty ()
259+ else "Failed to checkout new branch"
260+ )
272261 return 1
273262
274263 return 0
0 commit comments