Skip to content

Commit bca82e3

Browse files
committed
fix: preserve commit message when SDK raises post-completion error
- Return already-extracted commit message in ProcessError/Exception handlers instead of discarding it when the SDK throws after successful completion
1 parent 2537925 commit bca82e3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/claude_commit/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,20 @@ async def generate_commit_message(
526526
except ProcessError as e:
527527
if "progress" in locals() and progress is not None:
528528
progress.stop()
529+
# If we already extracted a commit message, return it despite the process error
530+
if commit_message:
531+
return commit_message
529532
error_console.print(f"[red]❌ Process error: {e}[/red]")
530533
if e.stderr:
531534
error_console.print(f" stderr: {e.stderr}")
532535
return None
533536
except Exception as e:
534537
if "progress" in locals() and progress is not None:
535538
progress.stop()
539+
# If we already extracted a commit message, return it despite the error
540+
# (the SDK sometimes raises after the CLI has already completed successfully)
541+
if commit_message:
542+
return commit_message
536543
error_console.print(f"[red]❌ Unexpected error: {e}[/red]")
537544
if verbose:
538545
import traceback

0 commit comments

Comments
 (0)