- Notifications
You must be signed in to change notification settings - Fork8.1k
Fix Move-Item with wildcard to non-existent destination flattening first directory#26604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
Copilot wants to merge14 commits intomasterChoose a base branch fromcopilot/fix-move-item-wildcard-issue
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+72 −9
Draft
Changes from1 commit
Commits
Show all changes
14 commits Select commitHold shift + click to select a range
10ba694 Initial plan
Copilot13cfcae Fix Move-Item wildcard bug - preserve directory structure
Copilotbd47771 Simplify fix by removing redundant parent existence check
Copilot2c8a38c Avoid duplicate ItemExists check by caching result
Copilotc038b6e Refactor to eliminate duplicate MakePath call
Copilot59e273c Revert "Refactor to eliminate duplicate MakePath call"
Copilot98a08c2 Fix: Only treat non-existent destination as container when parent exists
Copilot5369559 Fix wildcard move at SessionState level instead of provider
Copilote38c682 Fix: Use destination provider instance for creating destination direc…
Copilota3b381e Fix: Use destinationContext and add null checks
Copilote9881be Add verbose debug output to diagnose directory creation issue
Copilot77f0817 Add -Verbose switch to test to enable diagnostic output
Copilot9b18849 Fix wildcard move at cmdlet level instead of SessionState level
Copilot758bc57 Fix compile error: Use correct signature for InvokeProvider.Item.New
CopilotFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Refactor to eliminate duplicate MakePath call
Address code review feedback from@iSazonov:- Extract common destination path adjustment to single location- Use shouldAppendDirName flag to control whether to append directory name- Eliminates code duplication between the two branchesCo-authored-by: iSazonov <22290914+iSazonov@users.noreply.github.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
10 changes: 9 additions & 1 deletionsrc/System.Management.Automation/namespaces/FileSystemProvider.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5840,9 +5840,12 @@ protected override void MoveItem( | ||
| // Check destination existence once to avoid expensive duplicate check | ||
| bool destinationExists = ItemExists(destination); | ||
| bool shouldAppendDirName = false; | ||
| if (destinationExists && IsItemContainer(destination)) | ||
| { | ||
| // Destination exists and is a container, append directory name | ||
| shouldAppendDirName = true; | ||
| } | ||
| else if (!destinationExists) | ||
| { | ||
| @@ -5851,6 +5854,11 @@ protected override void MoveItem( | ||
| // multiple items with wildcards. | ||
| // CreateDirectory will create all parent directories as needed. | ||
| CreateDirectory(destination, false); | ||
| shouldAppendDirName = true; | ||
| } | ||
| if (shouldAppendDirName) | ||
| { | ||
| destination = MakePath(destination, dir.Name); | ||
iSazonov marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
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.