diff --git a/AU/Private/AUVersion.ps1 b/AU/Private/AUVersion.ps1 index 8e5587c2..ac240c09 100644 --- a/AU/Private/AUVersion.ps1 +++ b/AU/Private/AUVersion.ps1 @@ -41,6 +41,8 @@ class AUVersion : System.IComparable { if ($pr -and !$strict) { $pr = $pr.Replace(' ', '.') } if ($bm -and !$strict) { $bm = $bm.Replace(' ', '.') } # for now, chocolatey does only support SemVer v1 (no dot separated identifiers in pre-release): + if ($pr -and $strict -and $pr -like '*.*') { return $false } + if ($bm -and $strict -and $bm -like '*.*') { return $false } if ($pr) { $pr = $pr.Replace('.', '') } if ($bm) { $bm = $bm.Replace('.', '') } # diff --git a/tests/Get-Version.Tests.ps1 b/tests/Get-Version.Tests.ps1 index c99f677b..487d64ff 100644 --- a/tests/Get-Version.Tests.ps1 +++ b/tests/Get-Version.Tests.ps1 @@ -106,14 +106,13 @@ Describe 'Get-Version' -Tag getversion { } $testCases = @( - @{Value = '1.2-beta.3' ; ExpectedResult = '1.2-beta3'} - @{Value = '1.2+xyz.4' ; ExpectedResult = '1.2+xyz4'} - @{Value = '1.2-beta.3+xyz.4' ; ExpectedResult = '1.2-beta3+xyz4'} + @{Value = '1.2-beta.3'} + @{Value = '1.2+xyz.4'} + @{Value = '1.2-beta.3+xyz.4'} ) - It 'converts semver v2 to semver v1' -TestCases $testCases { param($Value, $ExpectedResult) - $version = [AUVersion] $Value - $version | Should Be ([AUVersion] $ExpectedResult) + It 'does not convert semver v2' -TestCases $testCases { param($Value, $ExpectedResult) + { [AUVersion] $Value } | Should Throw 'Invalid version' } $testCases = @(