Commit b077f24
fix(Git): use full Dependency.Target path when target doesn't exist (#169)
Supersedes #99 — that PR has been open since 2019 with no merge
activity, so filing a fresh one with the fixes applied.
## Problem
The `-Force` branch in `Git.ps1` used `Split-Path -Leaf` + `Join-Path
$PWD` to construct the target path. This breaks in two ways:
1. Absolute paths or multi-level targets (e.g. `C:\Temp\Repos\myrepo`,
`TestDrive:/PSDependPesterTest\buildhelpers`) are clobbered — only the
leaf is used and it lands in `$PWD` instead of the intended location.
2. When `-Force` is used without a `Dependency.Target`, `Split-Path`
throws because the input is empty.
## Fix
In the unresolvable-target `else` block, simply set `$Target =
$Dependency.Target` when it is non-empty. The existing `New-Item` call
at line 109 already handles directory creation for the `Install` action
— no duplication needed. When `Dependency.Target` is empty the previous
default-to-`$PWD` behavior is preserved.
## Changes
- `PSDepend/PSDependScripts/Git.ps1` — replaced the broken
`-Force`/`Split-Path` branch with a clean `$Dependency.Target`
assignment
- `Tests/PSModuleGallery.Type.Tests.ps1` — added a Pester regression
context that asserts `New-Item` is called with the full target path, not
just the leaf joined to `$PWD`
---------
Co-authored-by: Raúl Carboneras <rcarboneras@outlook.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent d792adb commit b077f24
2 files changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
515 | 533 | | |
516 | 534 | | |
517 | 535 | | |
| |||
0 commit comments