From f8316d71ce3a0a7b00770da5313a069db339c349 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 15 May 2026 16:07:34 -0700 Subject: [PATCH] fix(Get-Dependency): correct operator precedence in Parse-Dependency elseif conditions When DependencyType was set globally via PSDependOptions, PowerShell's -and/-or precedence caused the simple-string elseif branches to match even for hashtable-syntax dependencies, assigning the whole hashtable to Version instead of parsing it correctly. Parenthesise the (-not $DependencyType -or $DependencyType -eq 'X') sub-expression in all three branches (PSGalleryModule, GitHub, Git). Fixes #131 Co-Authored-By: Claude Sonnet 4.6 --- PSDepend/Public/Get-Dependency.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PSDepend/Public/Get-Dependency.ps1 b/PSDepend/Public/Get-Dependency.ps1 index 74fc769..7923caa 100644 --- a/PSDepend/Public/Get-Dependency.ps1 +++ b/PSDepend/Public/Get-Dependency.ps1 @@ -258,8 +258,8 @@ function Get-Dependency { # It doesn't look like a git repo, and simple syntax: PSGalleryModule elseif( $DependencyHash -is [string] -and $Dependency -notmatch '/' -and - -not $DependencyType -or - $DependencyType -eq 'PSGalleryModule') { + (-not $DependencyType -or + $DependencyType -eq 'PSGalleryModule')) { [PSCustomObject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -284,8 +284,8 @@ function Get-Dependency { elseif($DependencyHash -is [string] -and $Dependency -match '/' -and $Dependency.split('/').count -eq 2 -and - -not $DependencyType -or - $DependencyType -eq 'GitHub') { + (-not $DependencyType -or + $DependencyType -eq 'GitHub')) { [PSCustomObject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -308,8 +308,8 @@ function Get-Dependency { # It looks like a git repo, and simple syntax: Git elseif($DependencyHash -is [string] -and $Dependency -match '/' -and - -not $DependencyType -or - $DependencyType -eq 'Git' ) { + (-not $DependencyType -or + $DependencyType -eq 'Git')) { [PSCustomObject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile