@@ -229,47 +229,61 @@ main() {
229229 local summary_file=" docs/release/latest-major-changes-since-${base_version} .md"
230230 local new_summary_file=" docs/release/${intended_new_version} -major-changes-since-${base_version} .md"
231231 if [[ -f " $summary_file " ]]; then
232+ # Always remove the target file if it exists to ensure clean rename
232233 if [[ -f " $new_summary_file " ]]; then
233- print_warning " $new_summary_file already exists. Overwriting with latest summary ."
234+ print_warning " $new_summary_file already exists. Removing existing file ."
234235 rm -f " $new_summary_file "
236+ if [[ -f " $new_summary_file " ]]; then
237+ print_error " Failed to remove existing file: $new_summary_file "
238+ exit 1
239+ fi
235240 fi
241+
236242 print_status " Renaming $summary_file to $new_summary_file "
237243
238- # Perform the rename operation
239- if mv " $summary_file " " $new_summary_file " ; then
240- print_success " Successfully renamed summary file"
241-
242- # Handle git operations with better error handling
243- if git add " $new_summary_file " 2> /dev/null; then
244- print_status " Added new summary file to git"
245- else
246- print_warning " Failed to add new summary file to git (may already be tracked)"
247- fi
248-
249- # Remove old file from git if it exists
250- if git rm " $summary_file " 2> /dev/null; then
251- print_status " Removed old summary file from git"
252- else
253- print_warning " Old summary file not in git (already removed or never tracked)"
254- fi
255-
256- # Commit the changes
257- if git commit -m " docs(release): rename major changes summary for release $intended_new_version (refs #68)" 2> /dev/null; then
258- print_status " Committed summary file rename"
244+ # Perform the rename operation with explicit error checking
245+ if mv " $summary_file " " $new_summary_file " 2> /dev/null; then
246+ # Verify the rename actually succeeded
247+ if [[ -f " $new_summary_file " && ! -f " $summary_file " ]]; then
248+ print_success " Successfully renamed summary file"
259249
260- # Push the changes
261- if git push 2> /dev/null; then
262- print_success " Pushed summary file changes "
250+ # Handle git operations with better error handling
251+ if git add " $new_summary_file " 2> /dev/null; then
252+ print_status " Added new summary file to git "
263253 else
264- print_warning " Failed to push summary file changes (may already be up to date )"
254+ print_warning " Failed to add new summary file to git (may already be tracked )"
265255 fi
256+
257+ # Remove old file from git if it exists
258+ if git rm " $summary_file " 2> /dev/null; then
259+ print_status " Removed old summary file from git"
260+ else
261+ print_warning " Old summary file not in git (already removed or never tracked)"
262+ fi
263+
264+ # Commit the changes
265+ if git commit -m " docs(release): rename major changes summary for release $intended_new_version (refs #68)" 2> /dev/null; then
266+ print_status " Committed summary file rename"
267+
268+ # Push the changes
269+ if git push 2> /dev/null; then
270+ print_success " Pushed summary file changes"
271+ else
272+ print_warning " Failed to push summary file changes (may already be up to date)"
273+ fi
274+ else
275+ print_warning " Failed to commit summary file rename (no changes to commit)"
276+ fi
277+
278+ print_success " Committed and pushed $new_summary_file "
266279 else
267- print_warning " Failed to commit summary file rename (no changes to commit)"
280+ print_error " Rename operation appeared to succeed but file verification failed"
281+ print_error " Expected: $new_summary_file to exist and $summary_file to not exist"
282+ exit 1
268283 fi
269-
270- print_success " Committed and pushed $new_summary_file "
271284 else
272285 print_error " Failed to rename summary file from $summary_file to $new_summary_file "
286+ print_error " This may be due to file system permissions or the target file being locked"
273287 exit 1
274288 fi
275289 else
0 commit comments