Skip to content

fix(diff): friendly errors for missing base ref and empty repos #25

Description

@alimaandev

ripple diff uses git under the hood, so a broken/nonexistent ref or a dirty tree fails the run. Detect these cases in advance and report them as friendly RippleError messages instead of a raw git stack trace.

Acceptance criteria

  • A missing --base ref reports something like: base ref 'feature/x' not found (fetched heads: main, develop).
  • A repo with no commits yet (fresh git init, no HEAD) reports a clear "not a git repo / no commits yet" message instead of crashing.
  • Non-zero git exits keep their stderr in the error message so the underlying cause is still visible.
  • Unit tests cover: missing ref, empty repo, dirty-tree diff against HEAD~1 (should still work).

Where to look

  • src/commands/diff.ts (git invocations live there), src/utils/errors.ts for the error constructor style, src/utils/fs.ts for safe filesystem helpers.

Out of scope

  • Auto-fetching refs or changing the git strategy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions