Skip to content

Add external diff tool support via INSTA_DIFF_TOOL#844

Merged
max-sixty merged 2 commits intomitsuhiko:masterfrom
max-sixty:side-by-side
Dec 14, 2025
Merged

Add external diff tool support via INSTA_DIFF_TOOL#844
max-sixty merged 2 commits intomitsuhiko:masterfrom
max-sixty:side-by-side

Conversation

@max-sixty
Copy link
Copy Markdown
Collaborator

I think a nice solution to #843; would let any diff tool be used, including passing settings to that tool; so that something like side-by-side can work

PR description from Claude follows


When the INSTA_DIFF_TOOL environment variable is set, insta will use the specified tool to display snapshot diffs instead of the built-in diff.
The tool is invoked as: <old_file> <new_file>

Example usage:
export INSTA_DIFF_TOOL=delta
export INSTA_DIFF_TOOL=difftastic

The external tool output is captured and printed through normal channels, so it respects cargo test's output capture (diffs are hidden during cargo insta test just like the built-in diff).

🤖 Generated with Claude Code

Copy link
Copy Markdown

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

I tried it out, this works great for me! Left some other notes though.

Comment thread cargo-insta/src/cli.rs Outdated
Comment on lines +71 to +73
Environment variables:
INSTA_DIFF_TOOL External diff tool for displaying diffs (e.g., \"delta --side-by-side\").
Invoked as: <tool> [args...] <old_file> <new_file>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be nice if this was also available as a cli argument.

Comment thread insta/src/output.rs
max-sixty and others added 2 commits December 14, 2025 10:18
When the INSTA_DIFF_TOOL environment variable is set (or --diff-tool CLI
arg is provided), insta will use the specified tool to display snapshot
diffs instead of the built-in diff. The tool supports arguments and is
invoked as: <tool> [args...] <old_file> <new_file>

Example usage:
  export INSTA_DIFF_TOOL=delta
  export INSTA_DIFF_TOOL="delta --side-by-side"
  cargo insta review --diff-tool difftastic

The external tool output is captured and printed through normal channels,
so it respects cargo test's output capture (diffs are hidden during
`cargo insta test` just like the built-in diff).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The diff tool option is only useful for `cargo insta review` since
`accept` and `reject` don't display diffs - they just apply operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 5822a95 into mitsuhiko:master Dec 14, 2025
15 checks passed
@max-sixty max-sixty mentioned this pull request Dec 18, 2025
2 tasks
max-sixty added a commit that referenced this pull request Dec 18, 2025
## Summary

- Add external diff tool support via `INSTA_DIFF_TOOL` environment
variable (#844)
- Add `test.disable_nextest_doctest` config option to `insta.yaml`
(#842)
- Skip non-insta snapshot files in unreferenced detection (#846)
- Collect warnings from tests for display after run (#840)
- Update TOML serialization to be up-to-date and backwards-compatible
(#834)
- Support `clippy::needless_raw_strings` lint (#828)

## Test plan

- [x] All tests pass
- [x] All lints pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
@max-sixty max-sixty deleted the side-by-side branch December 29, 2025 03:16
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