Skip to content

Commit 5984523

Browse files
committed
👌 IMPROVE: formatting
1 parent 5140b54 commit 5984523

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

release.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,43 @@ def main():
259259
print("❌ Release cancelled")
260260
return
261261

262-
# Commit changes
262+
# Commit changes - handle pre-commit hooks properly
263263
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+
)
271299

272300
# Step 8: Ask to push to GitHub
273301
if not ask_yes_no("Push changes to GitHub?"):

0 commit comments

Comments
 (0)