@@ -249,6 +249,7 @@ def updateCoreRepo():
249249 git_cmds = [["git" , "-C" , repo_local_path , "clone" , gh_core ]]
250250 for cmd in git_cmds :
251251 execute_cmd (cmd , None )
252+ createBranch ()
252253
253254
254255def checkCoreRepo ():
@@ -268,6 +269,35 @@ def checkCoreRepo():
268269 exit (1 )
269270 status = execute_cmd (["git" , "-C" , core_path , "rev-parse" , "--abbrev-ref" , "HEAD" ], None )
270271 print (f"Current branch: { status .strip ()} " )
272+ createBranch ()
273+
274+
275+ def createBranch ():
276+ # Create a new branch for the update
277+ if upargs .serie :
278+ bname = f"stm32cube{ upargs .serie } _update"
279+ elif upargs .add :
280+ bname = f"stm32cube{ upargs .add } _addition"
281+ else :
282+ bname = "stm32cube_update"
283+ # Check if the branch already exists
284+ bname_list = [bn [2 :] for bn in execute_cmd (["git" , "-C" , core_path , "branch" , "--list" ], None ).splitlines ()]
285+ if (
286+ bname
287+ in bname_list
288+ ):
289+ print (f"Branch { bname } already exists, ..." )
290+ execute_cmd (["git" , "-C" , core_path , "checkout" , bname ], None )
291+ else :
292+ print (f"Creating branch { bname } ..." )
293+ execute_cmd (["git" , "-C" , core_path , "checkout" , "-b" , bname ], None )
294+ # Check if the branch was created successfully
295+ status = execute_cmd (
296+ ["git" , "-C" , core_path , "rev-parse" , "--abbrev-ref" , "HEAD" ], None
297+ )
298+ if status .strip () != bname :
299+ print (f"Failed to create branch { bname } !" )
300+ exit (1 )
271301
272302
273303def checkSTLocal ():
0 commit comments