test(snapshot): add extended test cases for revert functionality#9408
Closed
yimingll wants to merge 3 commits intoanomalyco:devfrom
Closed
test(snapshot): add extended test cases for revert functionality#9408yimingll wants to merge 3 commits intoanomalyco:devfrom
yimingll wants to merge 3 commits intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
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! |
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>
5405be6 to
aa40a36
Compare
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.spawninstead 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)
Code Changes
runGitCommandhelper - UsesBun.spawnfor reliable unicode filename handlingcore.quotepath=false- Configured in git init and all git commands to prevent path escapingAcknowledgments
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