[PR #9408] test(snapshot): add extended test cases for revert functionality #13097

Open
opened 2026-02-16 18:17:58 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9408

State: open
Merged: No


Fixes #8098

Summary

This PR extends the test coverage for the snapshot revert functionality and fixes unicode/emoji filename support, building upon the fix in PR #8631 by @Twisted928.

Bug Fix: Unicode Filename Support

The original fix in PR #8631 didn't handle unicode filenames (Chinese, Japanese, Korean, emoji) correctly on Windows. This was due to Bun's shell template (`$``) having issues passing non-ASCII characters to git.

Solution: Use Bun.spawn instead of shell templates for git commands that involve file paths, ensuring reliable unicode support across all platforms.

Added Test Cases (8 new tests - all passing)

Test Status Description
Unicode/Chinese filenames Verifies CJK character handling
Emoji filenames Verifies emoji in filenames
Symlink handling Verifies symlink target restoration
Large file handling Tests 1MB file revert
Binary file handling Tests binary data preservation
Concurrent operations Tests multiple file revert
Empty file handling Tests empty file restoration
Restore to empty state Tests content removal revert

Code Changes

  1. runGitCommand helper - Uses Bun.spawn for reliable unicode filename handling
  2. core.quotepath=false - Configured in git init and all git commands to prevent path escaping
  3. All 8 tests enabled - Previously 2 were skipped due to the unicode bug

Acknowledgments

This PR builds on the excellent work by @Twisted928 in PR #8631. The original fix correctly handles the absolute path issue - this PR extends it with unicode support and comprehensive test coverage.

Co-authored-by: Twisted 46923858+Twisted928@users.noreply.github.com

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9408 **State:** open **Merged:** No --- Fixes #8098 ## Summary This PR extends the test coverage for the snapshot revert functionality and **fixes unicode/emoji filename support**, building upon the fix in PR #8631 by @Twisted928. ### Bug Fix: Unicode Filename Support The original fix in PR #8631 didn't handle unicode filenames (Chinese, Japanese, Korean, emoji) correctly on Windows. This was due to Bun's shell template (`$\``) having issues passing non-ASCII characters to git. **Solution**: Use `Bun.spawn` instead of shell templates for git commands that involve file paths, ensuring reliable unicode support across all platforms. ### Added Test Cases (8 new tests - all passing) | Test | Status | Description | |------|--------|-------------| | Unicode/Chinese filenames | ✅ | Verifies CJK character handling | | Emoji filenames | ✅ | Verifies emoji in filenames | | Symlink handling | ✅ | Verifies symlink target restoration | | Large file handling | ✅ | Tests 1MB file revert | | Binary file handling | ✅ | Tests binary data preservation | | Concurrent operations | ✅ | Tests multiple file revert | | Empty file handling | ✅ | Tests empty file restoration | | Restore to empty state | ✅ | Tests content removal revert | ### Code Changes 1. **`runGitCommand` helper** - Uses `Bun.spawn` for reliable unicode filename handling 2. **`core.quotepath=false`** - Configured in git init and all git commands to prevent path escaping 3. **All 8 tests enabled** - Previously 2 were skipped due to the unicode bug ### Acknowledgments This PR builds on the excellent work by @Twisted928 in PR #8631. The original fix correctly handles the absolute path issue - this PR extends it with unicode support and comprehensive test coverage. Co-authored-by: Twisted <46923858+Twisted928@users.noreply.github.com>
yindo added the pull-request label 2026-02-16 18:17:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13097