Skip to content

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • When a snapshot file contains git merge conflict markers, insta now detects them and handles gracefully instead of panicking
  • Prints a warning and treats the snapshot as missing, allowing tests to continue
  • Creates a new pending snapshot for review

This improves the developer experience during merge conflict resolution - you can run tests to see what the correct output should be, then accept the new snapshot.

Test plan

  • Added test_snapshot_with_merge_conflict - conflict markers at start of file
  • Added test_snapshot_with_merge_conflict_in_yaml - conflict markers in YAML header
  • All 66 functional tests pass
  • Pre-commit lints pass

🤖 Generated with Claude Code

When a snapshot file contains git merge conflict markers, instead of
panicking with a parse error, insta now:
1. Detects the conflict markers (<<<<<<, =======, >>>>>>>)
2. Prints a warning about the unresolved conflicts
3. Treats the snapshot as missing, allowing the test to continue
4. Creates a new pending snapshot for review

This improves the developer experience during merge conflict resolution,
allowing tests to run and generate the correct snapshots.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 8838b2f into mitsuhiko:master Nov 27, 2025
15 checks passed
max-sixty added a commit to max-sixty/insta that referenced this pull request Nov 27, 2025
## Changes

- Fix backward compatibility for legacy inline snapshot format. Snapshots
  using single-line content in multiline raw strings now correctly match
  again. (mitsuhiko#830)
- Handle merge conflicts in snapshot files gracefully. When a snapshot file
  contains git merge conflict markers, insta now detects them and treats
  the snapshot as missing, allowing tests to continue and create a new
  pending snapshot for review. (mitsuhiko#829)
- Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826)
- Fix functional tests failing under nextest due to inherited
  `NEXTEST_RUN_ID` environment variable. (mitsuhiko#824)

## Version Updates

- Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml`
- Update CHANGELOG.md with release notes
- Update Cargo.lock

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

Co-authored-by: Claude <noreply@anthropic.com>
@max-sixty max-sixty mentioned this pull request Nov 27, 2025
2 tasks
max-sixty added a commit to max-sixty/insta that referenced this pull request Nov 27, 2025
## Changes

- Fix backward compatibility for legacy inline snapshot format. Snapshots
  using single-line content in multiline raw strings now correctly match
  again. (mitsuhiko#830)
- Handle merge conflicts in snapshot files gracefully. When a snapshot file
  contains git merge conflict markers, insta now detects them and treats
  the snapshot as missing, allowing tests to continue and create a new
  pending snapshot for review. (mitsuhiko#829)
- Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826)
- Fix functional tests failing under nextest due to inherited
  `NEXTEST_RUN_ID` environment variable. (mitsuhiko#824)

## Version Updates

- Bump version to 1.44.2 in `insta/Cargo.toml` and `cargo-insta/Cargo.toml`
- Update CHANGELOG.md with release notes
- Update Cargo.lock

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

Co-authored-by: Claude <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request Nov 27, 2025
## Summary

Prepare for the 1.44.2 patch release with four changes since 1.44.1.

## Changes

- Fix backward compatibility for legacy inline snapshot format.
Snapshots using single-line content in multiline raw strings now
correctly match again. (#830)
- Handle merge conflicts in snapshot files gracefully. When a snapshot
file contains git merge conflict markers, insta now detects them and
treats the snapshot as missing, allowing tests to continue and create a
new pending snapshot for review. (#829)
- Skip nextest_doctest tests when cargo-nextest is not installed. (#826)
- Fix functional tests failing under nextest due to inherited
`NEXTEST_RUN_ID` environment variable. (#824)

## Version Updates

- Bump version to 1.44.2 in `insta/Cargo.toml` and
`cargo-insta/Cargo.toml`
- Update CHANGELOG.md with release notes
- Update Cargo.lock

## Test plan

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

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

Co-authored-by: Claude <noreply@anthropic.com>
@max-sixty max-sixty deleted the test-conflict branch November 27, 2025 06:25
max-sixty pushed a commit to max-sixty/insta that referenced this pull request Nov 27, 2025
The merge conflict handling introduced in mitsuhiko#829 was too aggressive - it
detected patterns like `======` in valid snapshot content and falsely
flagged them as merge conflicts.

This fix changes the approach:
- First attempt to parse the snapshot normally
- Only if parsing FAILS, check for merge conflict markers
- If markers found after parse failure, show warning and treat as missing
- If no markers, propagate the original parse error

This ensures valid snapshots with separator patterns (e.g., CLI output
with `==============================`) are not incorrectly ignored.

Added tests:
- test_snapshot_with_equals_in_content_not_conflict: regression test for mitsuhiko#832
- test_snapshot_with_merge_conflict: conflict markers at start of file
- test_snapshot_with_merge_conflict_in_yaml: conflict markers in YAML header
max-sixty added a commit to max-sixty/insta that referenced this pull request Nov 27, 2025
## Summary

Prepare for the 1.44.2 patch release with four changes since 1.44.1.

## Changes

- Fix backward compatibility for legacy inline snapshot format.
Snapshots using single-line content in multiline raw strings now
correctly match again. (mitsuhiko#830)
- Handle merge conflicts in snapshot files gracefully. When a snapshot
file contains git merge conflict markers, insta now detects them and
treats the snapshot as missing, allowing tests to continue and create a
new pending snapshot for review. (mitsuhiko#829)
- Skip nextest_doctest tests when cargo-nextest is not installed. (mitsuhiko#826)
- Fix functional tests failing under nextest due to inherited
`NEXTEST_RUN_ID` environment variable. (mitsuhiko#824)

## Version Updates

- Bump version to 1.44.2 in `insta/Cargo.toml` and
`cargo-insta/Cargo.toml`
- Update CHANGELOG.md with release notes
- Update Cargo.lock

## Test plan

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

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

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant