Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions PSDepend/PSDependScripts/Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ if($Dependency.Target -and ($Target = (Get-Item $Dependency.Target -ErrorAction
}
else
{
$Target = $PWD.Path
Write-Debug "Target defaulted to current dir: $Target"
if ($Dependency.Target) {
$Target = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Dependency.Target)
Write-Debug "Target $($Dependency.Target) does not exist yet, will be created"
}
else {
$Target = $PWD.Path
Write-Debug "Target defaulted to current dir: $Target"
}
}
$RepoPath = Join-Path $Target $GitName
$GottaInstall = $True
Expand Down
18 changes: 18 additions & 0 deletions Tests/PSModuleGallery.Type.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,24 @@ Describe "PSModuleGallery Type" -Tag 'Integration' {
}
}

Context 'Creates non-existent Target directory using full path' {
BeforeAll {
Mock Invoke-ExternalCommand {} -ModuleName PSDepend -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' }
Mock Push-Location {} -ModuleName PSDepend
Mock Pop-Location {} -ModuleName PSDepend
Mock Set-Location {} -ModuleName PSDepend
Mock Test-Path { return $False } -ModuleName PSDepend -ParameterFilter { $Path -match 'buildhelpers' }
Mock New-Item { [pscustomobject]@{ FullName = $Path } } -ModuleName PSDepend
$null = Invoke-PSDepend @Verbose -Path "$TestDepends\git.depend.psd1" -Force
}

It 'Calls New-Item with a path containing the full target name, not just the leaf joined to $PWD' {
Should -Invoke New-Item -Times 1 -Exactly -Scope Context -ModuleName PSDepend -ParameterFilter {
$Path -match 'buildhelpers' -and $Path -notmatch [regex]::Escape($PWD.Path)
}
}
}

Context 'Tests dependency' {
BeforeAll {
Mock New-Item { return $true } -ModuleName PSDepend
Expand Down
Loading