Skip to content

test(snapshot): add extended test cases for revert functionality#9408

Closed
yimingll wants to merge 3 commits intoanomalyco:devfrom
yimingll:fix/snapshot-revert-extended-tests
Closed

test(snapshot): add extended test cases for revert functionality#9408
yimingll wants to merge 3 commits intoanomalyco:devfrom
yimingll:fix/snapshot-revert-extended-tests

Conversation

@yimingll
Copy link
Copy Markdown

@yimingll yimingll commented Jan 19, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@yimingll
Copy link
Copy Markdown
Author

@thdxr @adamdotdevin Could you please review this PR? It includes a fix for the revert functionality (building on PR #8631) with additional unicode/emoji filename support and comprehensive test coverage. I've tested it locally and confirmed it works correctly. Thank you!

dcm and others added 3 commits January 19, 2026 22:58
Root cause: Snapshot.patch() returns absolute paths in files array, but
git checkout expects paths relative to worktree, causing checkout to fail
silently and files not being restored.

Changes:
- Convert absolute paths to relative using path.relative()
- Add safety guards: worktree escape check, empty path check
- Normalize path separators for Windows compatibility
- Add fs.mkdir() before fs.writeFile() in git show fallback
- Add 13 test cases covering the fix and edge cases

Fixes TUI Revert not actually reverting file changes in workspace.
Based on PR anomalyco#8631 by @Twisted928, this adds 8 additional test scenarios:
- Unicode/Chinese character filenames (skipped - reveals bug)
- Emoji filenames (skipped - reveals bug)
- Symlink handling
- Large file handling (1MB)
- Binary file handling
- Concurrent operations
- Empty file handling
- Restore to empty state

Co-authored-by: Twisted <46923858+Twisted928@users.noreply.github.com>
Use Bun.spawn instead of shell template for git commands to properly
handle unicode filenames on Windows. The Bun shell ($`) has issues
passing non-ASCII characters to git on Windows.

Changes:
- Add runGitCommand helper using Bun.spawn for reliable unicode support
- Configure core.quotepath=false in git init and all git commands
- Enable unicode/emoji filename tests (previously skipped)

All 8 new test cases now pass:
- Unicode/Chinese character filenames
- Emoji filenames
- Symlink handling
- Large file handling (1MB)
- Binary file handling
- Concurrent operations
- Empty file handling
- Restore to empty state

Co-authored-by: Twisted <46923858+Twisted928@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions bot closed this Mar 21, 2026
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.

i input /undo just undo conversation,not file

1 participant