Skip to content

Commit

Permalink
scripts: update: commit systematically the update
Browse files Browse the repository at this point in the history
Not committing cube update leave some trailing space
and this cause confusion and misunderstanding.
So Cube update is now systematically committed.
Remove "--force" option

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM authored and erwango committed Nov 29, 2021
1 parent 710720d commit f9fe0cc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 72 deletions.
77 changes: 35 additions & 42 deletions scripts/serie_update.py
Expand Up @@ -49,7 +49,6 @@ def __init__(
self,
stm32_serie,
stm32cube_repo_path,
force,
noclean,
version_update,
debug,
Expand All @@ -59,7 +58,6 @@ def __init__(
Args:
stm32_serie: stm32 serie ex:stm32f3xx
stm32cube_repo_path: directory path where to fetch github repo
force: boolean to force or not git commit after applying update
noclean: boolean to clean or not github repo after update done
version_update: string to force a specified version to be updated
debug: boolean to set log debug level
Expand All @@ -82,7 +80,6 @@ def __init__(
self.stm32_serie_upper = stm32_serie.upper() # ex:STM32F3
self.stm32_seriexx_upper = self.stm32_serie_upper + "xx" # ex:STM32F3xx
self.serie = self.stm32_serie_upper[5:]
self.force = force
self.noclean = noclean
self.version_update = version_update
self.debug = debug
Expand Down Expand Up @@ -649,47 +646,43 @@ def apply_zephyr_patch(self):

def merge_commit(self, lib=False):
"""Apply zephyr stm32 patch to latest stm32Cube version"""
# Merge & commit if needed
if self.force:
# to clean the .rej files, uncomment line: reject()
# reject()
if lib:
logging.info("%s", "commit BLE library update")
commit_msg = "lib/stm32: "
else:
logging.info("%s", "commit HAL/LL Cube update ")
commit_msg = "stm32cube: "

commit_file_path = self.zephyr_module_serie_path / "commit.msg"
with open(commit_file_path, "w") as commit:
commit.write(
commit_msg
+ "update "
+ self.stm32_serie
+ " to cube version "
+ self.version_update.upper()
+ "\n"
)

commit.write("\n")
commit.write(
"Update Cube version for "
+ self.stm32_seriexx_upper
+ " series"
+ "\n"
)
commit.write("on https://github.com/STMicroelectronics" + "\n")
commit.write(f"from version {self.current_version}\n")
commit.write(f"to version {self.version_update}\n")
self.os_cmd(
("git", "commit", "-as", "-F", commit_file_path),
cwd=self.zephyr_module_serie_path,
# Merge & commit
# to clean the .rej files, uncomment line: reject()
# reject()
if lib:
logging.info("%s", "commit BLE library update")
commit_msg = "lib/stm32: "
else:
logging.info("%s", "commit HAL/LL Cube update ")
commit_msg = "stm32cube: "

commit_file_path = self.zephyr_module_serie_path / "commit.msg"
with open(commit_file_path, "w") as commit:
commit.write(
commit_msg
+ "update "
+ self.stm32_serie
+ " to cube version "
+ self.version_update.upper()
+ "\n"
)
self.os_cmd(
("git", "rebase", "--whitespace=fix", "HEAD~1"),
cwd=self.zephyr_module_serie_path,

commit.write("\n")
commit.write(
"Update Cube version for " + self.stm32_seriexx_upper + " series" + "\n"
)
Path(commit_file_path).unlink()
commit.write("on https://github.com/STMicroelectronics" + "\n")
commit.write(f"from version {self.current_version}\n")
commit.write(f"to version {self.version_update}\n")
self.os_cmd(
("git", "commit", "-as", "-F", commit_file_path),
cwd=self.zephyr_module_serie_path,
)
self.os_cmd(
("git", "rebase", "--whitespace=fix", "HEAD~1"),
cwd=self.zephyr_module_serie_path,
)
Path(commit_file_path).unlink()

def reject(self):
"""Clean *.rej files"""
Expand Down
47 changes: 17 additions & 30 deletions scripts/update_stm32_package.py
Expand Up @@ -37,16 +37,6 @@
default=False,
help="Do NOT clean the STM32Cube repo directory",
)
parser.add_argument(
"-f",
"--force",
action="store_true",
default=False,
help="Forces the merge except .rej files \n"
+ "applicable only with -s option. "
+ "Otrherwise merge is forced systematically "
+ "for each serie",
)
parser.add_argument(
"-r",
"--repo",
Expand Down Expand Up @@ -92,7 +82,6 @@ def update_cubes():
update_serie = serie_update.Stm32SerieUpdate(
stmyyxx.name[:-2],
repo_path,
force=True,
noclean=args.noclean,
debug=args.debug,
version_update="",
Expand Down Expand Up @@ -158,7 +147,6 @@ def update_cubes():
update = serie_update.Stm32SerieUpdate(
args.stm32_serie,
repo_path,
args.force,
args.noclean,
args.version,
args.debug,
Expand All @@ -182,24 +170,23 @@ def update_cubes():
genllheaders.main(REPO_ROOT / "stm32cube", REPO_ROOT / "stm32cube" / "common_ll")

# commit autogenerate generic LL HAL headers
if args.force:
commit_file_path = REPO_ROOT / "commit.msg"
with open(commit_file_path, "w") as commit:
commit.write("stm32cube: common_ll: Regeneration after cube updates\n")
commit.write("\n")
commit.write("Re - generate common_ll headers after Cube updates\n")

subprocess.check_call(
("git", "commit", "-as", "-F", commit_file_path),
cwd=REPO_ROOT,
)
commit_file_path = REPO_ROOT / "commit.msg"
with open(commit_file_path, "w") as commit:
commit.write("stm32cube: common_ll: Regeneration after cube updates\n")
commit.write("\n")
commit.write("Re - generate common_ll headers after Cube updates\n")

subprocess.check_call(
("git", "commit", "-as", "-F", commit_file_path),
cwd=REPO_ROOT,
)

subprocess.check_call(
("git", "rebase", "--whitespace=fix", "HEAD~1"),
stdout=std_dest,
stderr=std_dest,
cwd=REPO_ROOT,
)
Path(commit_file_path).unlink()
subprocess.check_call(
("git", "rebase", "--whitespace=fix", "HEAD~1"),
stdout=std_dest,
stderr=std_dest,
cwd=REPO_ROOT,
)
Path(commit_file_path).unlink()

logging.info("%s", "LL HAL header update: Done")

0 comments on commit f9fe0cc

Please sign in to comment.