Skip to content

Conversation

@ereslibre
Copy link
Collaborator

@ereslibre ereslibre commented Sep 10, 2025

Improve git command error handling across the codebase by adding the reject: false option to prevent throwing errors and remove duplicate console output from task validation.

This change makes git operations more resilient by handling errors gracefully instead of throwing exceptions, and eliminates redundant error messages shown to users.

Changes

  • Added reject: false option to all launchSync git commands in packages/common/src/git.ts to prevent throwing on non-zero exit codes
  • Removed duplicate console output for "no commits found" error in packages/cli/src/commands/task.ts
  • Fixed git availability check comment from "docker" to "git" in Git constructor
  • Improved error handling consistency across git operations like isGitRepo(), getRepositoryRoot(), hasCommits(), branchExists(), and createWorktree()

Notes

The reject: false option allows git commands to return exit codes without throwing exceptions, enabling proper error handling through exit code checking rather than try/catch blocks. This approach provides better control over error scenarios and reduces unexpected crashes.

Closes #151

@ereslibre ereslibre force-pushed the fix-git-error-messages branch 3 times, most recently from 8f2c05f to 870f65f Compare September 10, 2025 07:21
@ereslibre ereslibre self-assigned this Sep 10, 2025
When we check the exit code of commands, do not throw if they have an
exit code other than 0 (default execa behavior), otherwise our check
will never be performed since we will raise to the next stack call.
@ereslibre ereslibre force-pushed the fix-git-error-messages branch from 870f65f to 62aa87d Compare September 10, 2025 07:23
Copy link
Contributor

@Angelmmiguel Angelmmiguel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ereslibre ereslibre merged commit 2f41f81 into main Sep 10, 2025
4 checks passed
@ereslibre ereslibre deleted the fix-git-error-messages branch September 10, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add specific tip if the git repo is initialized but has no commits

3 participants