@@ -259,15 +259,43 @@ def main():
259
259
print ("❌ Release cancelled" )
260
260
return
261
261
262
- # Commit changes
262
+ # Commit changes - handle pre-commit hooks properly
263
263
commit_message = f"🚀 RELEASE: v{ new_version } \n \n { release_message } "
264
- success , _ = run_command (
265
- f'git add . && git commit -m "{ commit_message } "' ,
266
- "Committing version changes" ,
267
- )
268
- if not success :
269
- print ("❌ Failed to commit changes" )
270
- sys .exit (1 )
264
+
265
+ # Try to commit with proper pre-commit hook handling
266
+ max_retries = 3
267
+ for attempt in range (max_retries ):
268
+ # Stage all changes before each attempt
269
+ success , _ = run_command (
270
+ "git add ." , f"Staging changes (attempt { attempt + 1 } )"
271
+ )
272
+ if not success :
273
+ print ("❌ Failed to stage changes" )
274
+ sys .exit (1 )
275
+
276
+ # Try to commit
277
+ success , output = run_command (
278
+ f'git commit -m "{ commit_message } "' ,
279
+ f"Committing version changes (attempt { attempt + 1 } )" ,
280
+ )
281
+
282
+ if success :
283
+ print ("✅ Successfully committed changes" )
284
+ break
285
+
286
+ # If this was the last attempt, fail
287
+ if attempt == max_retries - 1 :
288
+ print ("❌ Failed to commit changes after multiple attempts" )
289
+ print (f"📤 Last error output: { output } " )
290
+ sys .exit (1 )
291
+
292
+ # If pre-commit hooks modified files, the next iteration will re-stage them
293
+ if "files were modified by this hook" in output :
294
+ print (f"🔄 Pre-commit hooks modified files, will re-stage and retry..." )
295
+ else :
296
+ print (
297
+ f"🔄 Commit failed, retrying... (attempt { attempt + 1 } /{ max_retries } )"
298
+ )
271
299
272
300
# Step 8: Ask to push to GitHub
273
301
if not ask_yes_no ("Push changes to GitHub?" ):
0 commit comments