Skip to content

Commit 96efad4

Browse files
committed
ci(stm32cube): create a dedicated branch
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 48f4404 commit 96efad4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

CI/update/stm32cube.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

254255
def 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

273303
def checkSTLocal():

0 commit comments

Comments
 (0)