Skip to content

fix(cli): exit nonzero when add rejects pending Git changes - #587

Open
pcbeingused33 wants to merge 1 commit into
TanStack:mainfrom
pcbeingused33:fix/add-dirty-git-exit
Open

pcbeingused33 wants to merge 1 commit into
TanStack:mainfrom
pcbeingused33:fix/add-dirty-git-exit

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

When tanstack add encounters pending Git changes, it prints a diagnostic and returns normally. Scripts therefore see exit code 0 even though no add-on was installed.

Throw an error from the Git guard so the existing CLI handler prints the same guidance and exits with code 1. The guard still honors --forced.

A regression test checks that pending changes reject the add operation. A focused Node 24 reproduction using the command handler, the Git guard, and a temporary Git repository observed exit code 0 before the fix and 1 after it. The forced invocation reached the installation path. In packages/create, the new test fails on main (the promise resolves instead of rejecting) and passes with the fix; the rest of tests/add-to-app.test.ts still passes. The full build was not run; the package tests that failed locally (copy-assets, edge/worker manifest, edge import) depend on build output and do not touch this code.

AI assistance was used to prepare the fix and regression test.

Summary by CodeRabbit

  • Bug Fixes
    • Add-on operations now report pending Git changes as an error and stop when not forced. Enabling the forced option bypasses this check.

@changeset-bot

changeset-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7a58f39

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When Git reports pending changes, addToApp now throws an error unless forced is true. A test checks rejection when Git reports an untracked file.

Changes: Pending Git Changes

Layer / File(s) Summary
Pending-changes guard and test
packages/create/src/add-to-app.ts, packages/create/tests/add-to-app.test.ts
When Git reports pending changes and forced is not true, addToApp throws an error. The test checks the error message when Git reports an untracked file.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: jherr, tannerlinsley

Merge Risk: Minimal · up to 7a58f

The add command now exits with an error when pending Git changes are present, instead of reporting the problem and exiting successfully. The forced option still bypasses the check. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(cli): exit nonzero when add rejects pending Git changes" matches the main change. The raw summary says addToApp now throws when Git reports pending changes and forced is not set, and th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(cli): exit nonzero when add rejects pending Git changes" matches the main change. The raw summary says addToApp now throws when Git reports pending changes and forced is not set, and the test covers the rejection. The title names the behavior change (nonzero exit on rejection) and the trigger (pending Git changes). It is specific and does not list files. The title is a conventional-commit style single sentence of 9 words.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8493636-3536-40d5-a573-c8ac9c8bd71e
Commits

Reviewing files that changed from the base of the PR and between 40e0043 and 7a58f39.

Files selected for processing: 2

  • packages/create/src/add-to-app.ts
  • packages/create/tests/add-to-app.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@tannerlinsley

tannerlinsley commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Thanks for catching this! Returning success when nothing was installed can hide a failed add operation in scripts. The guard change looks right.

AI review notes:
Reviewed the full two-file diff at 7a58f393164906019e8923d97b57477f660b8727 against 40e0043707b23b498c6a32950404893817a6f2c3. No dependency, hook or workflow changes.
The regression fails against the base guard and passes with this fix. A generated blank app outside the monorepo, initialized as a dirty Git repository, now exits 1 from the actual CLI with the commit-or-stash guidance. Existing forced add tests pass.
A clean frozen install, all 10 repository builds, lint and all 571 unit tests pass on Node 26.3.1. All 22 blocking browser checks also pass, including generated apps outside the monorepo. No hosted CI success or merge is claimed.
Required fork CI runs are waiting for direct GitHub execution, with no Core-owned paths changed. The current branch rules do not require a separate Core approval for this diff.

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.

2 participants