Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-move-item-wildcard-issue
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
10ba694
Initial plan
CopilotDec 11, 2025
13cfcae
Fix Move-Item wildcard bug - preserve directory structure
CopilotDec 11, 2025
bd47771
Simplify fix by removing redundant parent existence check
CopilotDec 11, 2025
2c8a38c
Avoid duplicate ItemExists check by caching result
CopilotDec 11, 2025
c038b6e
Refactor to eliminate duplicate MakePath call
CopilotDec 11, 2025
59e273c
Revert "Refactor to eliminate duplicate MakePath call"
CopilotDec 11, 2025
98a08c2
Fix: Only treat non-existent destination as container when parent exists
CopilotDec 11, 2025
5369559
Fix wildcard move at SessionState level instead of provider
CopilotDec 11, 2025
e38c682
Fix: Use destination provider instance for creating destination direc…
CopilotDec 11, 2025
a3b381e
Fix: Use destinationContext and add null checks
CopilotDec 11, 2025
e9881be
Add verbose debug output to diagnose directory creation issue
CopilotDec 11, 2025
77f0817
Add -Verbose switch to test to enable diagnostic output
CopilotDec 11, 2025
9b18849
Fix wildcard move at cmdlet level instead of SessionState level
CopilotDec 11, 2025
758bc57
Fix compile error: Use correct signature for InvokeProvider.Item.New
CopilotDec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix Move-Item wildcard bug - preserve directory structure
Co-authored-by: iSazonov <22290914+iSazonov@users.noreply.github.com>
  • Loading branch information
@iSazonov
Copilot andiSazonov committedDec 11, 2025
commit13cfcae4026e08320526de8ed79097824f43ff52
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5843,6 +5843,19 @@ protected override void MoveItem(
{
destination = MakePath(destination, dir.Name);
}
else if (!ItemExists(destination))
{
// When destination doesn't exist, check if its parent exists.
// If so, treat destination as a container to preserve the source directory name.
// This ensures consistent behavior when moving multiple items with wildcards.
string parentPath = GetParentPath(destination, null);
if (!string.IsNullOrEmpty(parentPath) && ItemExists(parentPath))
{
// Create the destination directory first
CreateDirectory(destination, false);
destination = MakePath(destination, dir.Name);
}
}

// Don't allow moving a directory into itself or its sub-directory.
string pathWithoutEndingSeparator = Path.TrimEndingDirectorySeparator(path);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,4 +110,39 @@ Describe "Move-Item tests" -Tag "CI" {
$renameToPath | Should -FileContentMatchExactly $booContent
}
}

Context "Move-Item with wildcard source and non-existent destination" {
BeforeEach {
$sourcePath = "$TESTDRIVE/install"
$destPath = "$TESTDRIVE/copy"

# Setup directory structure
New-Item -ItemType Directory -Path "$sourcePath/bin" -Force | Out-Null
New-Item -ItemType File -Path "$sourcePath/bin/test.dll" | Out-Null
New-Item -ItemType Directory -Path "$sourcePath/lib" | Out-Null
New-Item -ItemType File -Path "$sourcePath/ReadMe.md" -Value "readme content" | Out-Null
New-Item -ItemType Directory -Path $destPath | Out-Null
}

AfterEach {
Remove-Item "$TESTDRIVE/install" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "$TESTDRIVE/copy" -Recurse -Force -ErrorAction SilentlyContinue
}

It "Should preserve directory structure when moving with wildcard to non-existent destination" {
Move-Item -Path "$sourcePath/*" -Destination "$destPath/app"

# Verify all items were moved
"$sourcePath/bin" | Should -Not -Exist
"$sourcePath/lib" | Should -Not -Exist
"$sourcePath/ReadMe.md" | Should -Not -Exist

# Verify directory structure is preserved (bin should not be flattened)
"$destPath/app/bin" | Should -Exist
"$destPath/app/bin/test.dll" | Should -Exist
"$destPath/app/lib" | Should -Exist
"$destPath/app/ReadMe.md" | Should -Exist
"$destPath/app/ReadMe.md" | Should -FileContentMatchExactly "readme content"
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp