[create-cloudflare] Handle git commit failures gracefully#12269
[create-cloudflare] Handle git commit failures gracefully#12269
Conversation
🦋 Changeset detectedLatest commit: 0d36d27 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @penalosa's task —— View job Changeset Review
✅ All changesets look good The changeset
The changeset appropriately describes this as a bug fix where git commit failures now no longer crash the setup process, and provides good context about the scenario (GPG signing issues). |
| } catch { | ||
| s.stop(`${brandColor("git")} ${dim(`commit failed`)}`); | ||
| updateStatus( | ||
| "Failed to create initial commit. Your changes have been staged but not committed. You can commit manually later.", |
There was a problem hiding this comment.
@claude the changes may not have been staged, since git add could have failed. Make this error message something like "Failed to create initial commit. You can commit manually later."
There was a problem hiding this comment.
Claude finished @penalosa's task —— View job
Fixed Error Message ✅
Updated the error message to be more accurate since git add could fail before staging any changes.
Todo List:
-
Install dependencies(Not needed for this simple change) - Read the current git.ts implementation
- Update the error message to be more generic
-
Run code quality checks(Simple text change, low risk) - Commit and push changes
Analysis: I can see the issue in packages/create-cloudflare/src/git.ts:102. The try-catch block wraps both git add (lines 85-88) and git commit (lines 90-96), but the error message assumes that staging succeeded. If git add fails, the changes would not have been staged, making the message misleading.
Fixed: Updated the error message from:
"Failed to create initial commit. Your changes have been staged but not committed. You can commit manually later."
to:
"Failed to create initial commit. You can commit manually later."
This makes the message accurate regardless of whether git add or git commit failed, addressing the Devin review feedback as well.
Changes pushed to branch fix/6965-git-commit-error-handling
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Make error message generic since git add could also fail Co-authored-by: Somhairle MacLeòid <penalosa@users.noreply.github.com>
Fixes #6965.
When creating the initial git commit fails (for example, when GPG signing is cancelled or misconfigured), the setup process now continues instead of crashing. A message is displayed informing the user that the commit was skipped and they can commit manually later.
The
gitCommitfunction inpackages/create-cloudflare/src/git.tspreviously lacked try-catch error handling around the git commit operation, unlike other git-related functions in the same file (e.g.,initializeGit,isGitConfigured,isInsideGitRepo,getProductionBranch). This caused the entire C3 setup process to abort when the commit failed.