@@ -146,13 +146,41 @@ def ensure_update_scripts_folder(calver: str, dry_run: bool) -> bool:
146146 if target .exists ():
147147 return False
148148 if upcoming .exists ():
149+ pre_update_path = upcoming / "pre_update.sh"
150+ if not pre_update_path .exists ():
151+ raise RuntimeError (f"Missing pre_update.sh in { upcoming } " )
149152 print (f"Renaming update scripts: upcoming -> { calver } " )
150153 run_git_command (["mv" , upcoming .as_posix (), target .as_posix ()], dry_run )
151154 return True
152155 print ("No upcoming update scripts folder found; skipping rename." )
153156 return False
154157
155158
159+ def ensure_pre_update_script_exists (calver : str , update_scripts_changed : bool , dry_run : bool ) -> bool :
160+ target = UPDATE_SCRIPTS_DIR / calver
161+ upcoming = UPDATE_SCRIPTS_DIR / "upcoming"
162+
163+ if target .exists () or update_scripts_changed :
164+ target_dir = target
165+ elif upcoming .exists ():
166+ target_dir = upcoming
167+ else :
168+ print ("No update scripts directory found to ensure pre_update.sh; skipping." )
169+ return False
170+
171+ pre_update_path = target_dir / "pre_update.sh"
172+ if pre_update_path .exists ():
173+ return False
174+
175+ print (f"Creating missing pre_update.sh in { target_dir } " )
176+ if dry_run :
177+ print (f"DRY-RUN: would write { pre_update_path } " )
178+ return True
179+
180+ pre_update_path .write_text ("#!/bin/bash\n \n " "set -euo pipefail\n \n " "# Intentionally left blank.\n " )
181+ return True
182+
183+
156184def stage_if_exists (path : Path , dry_run : bool ) -> None :
157185 if dry_run :
158186 print (f"DRY-RUN: $ git add { path .as_posix ()} " )
@@ -203,18 +231,25 @@ def main(argv: list[str]) -> int:
203231 release_version_changed = ensure_release_version (calver , dry_run = args .dry_run )
204232 changelog_changed = ensure_changelog_top_matches (calver , dry_run = args .dry_run )
205233 update_scripts_changed = ensure_update_scripts_folder (calver , dry_run = args .dry_run )
234+ pre_update_created = ensure_pre_update_script_exists (
235+ calver , update_scripts_changed = update_scripts_changed , dry_run = args .dry_run
236+ )
206237
207238 if release_version_changed :
208239 stage_if_exists (VERSION_FILE , dry_run = args .dry_run )
209240 if changelog_changed :
210241 stage_if_exists (CHANGELOG_FILE , dry_run = args .dry_run )
211- if update_scripts_changed :
242+ if update_scripts_changed or pre_update_created :
212243 stage_if_exists (UPDATE_SCRIPTS_DIR , dry_run = args .dry_run )
213244 if fe_build_changed :
214245 stage_if_exists (FE_BUILD_DIR , dry_run = args .dry_run )
215246
216247 need_release_commit = args .dry_run and (
217- release_version_changed or changelog_changed or update_scripts_changed or fe_build_changed
248+ release_version_changed
249+ or changelog_changed
250+ or update_scripts_changed
251+ or pre_update_created
252+ or fe_build_changed
218253 )
219254 if not args .dry_run :
220255 need_release_commit = git_diff_cached_has_changes ()
0 commit comments