-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(versions): Refactor compare_versions
-> Compare-Version
#3333
Conversation
More tests: describe "versions" -Tag 'Scoop' {
it 'compares versions with integer-string mismatch' {
compare_versions '1.8.9' '1.8.5-1' | Should -Be 1
}
it 'handles plain string version comparison to int version' {
compare_versions 'latest' '20150405' | Should -Be 1
}
it 'handles dashed version components' {
compare_versions '7.0.4-9' '7.0.4-10' | Should -Be -1
compare_versions '7.0.4' '7.0.4-9' | Should -Be -1
compare_versions '7.0.4-9' '7.0.4-10' | Should -Be -1
}
it 'handle example comparisons' {
compare_versions '1' '1.1' | Should -Be -1
compare_versions '1.0' '1.1' | Should -Be -1
compare_versions '1.1' '1.0' | Should -Be 1
compare_versions '1.1' '1' | Should -Be 1
compare_versions '1.1.1_8' '1.1.1' | Should -Be 1
compare_versions '1.1.1b' '1.1.1a' | Should -Be 1
compare_versions '1.1.1a' '1.1.1b' | Should -Be -1
compare_versions '2019-01-01' '2019-01-02' | Should -Be -1
compare_versions '2019-01-02' '2019-01-01' | Should -Be 1
compare_versions '2018-01-01' '2019-01-01' | Should -Be -1
compare_versions '2019-01-01' '2018-01-01' | Should -Be 1
}
it 'handles comparsion against en empty string' {
compare_versions '7.0.4-9' '' | Should -Be 1
}
it 'handles equal versions' {
compare_versions '12.0' '12.0' | Should -Be 0
compare_versions '7.0.4-9' '7.0.4-9' | Should -Be 0
}
} By checking if if($a -eq $b) {
return 0
} |
Related issue: ScoopInstaller/Extras#2106 Maybe we could remove the version comparison entirely like @se35710 mentioned. Comparing versions that don't follow a schema like semver.org is pretty much useless anyway. But there are more normal versions then odd ones. See below (includes Main/Extras/Versions and outdated Java/PHP/NerdFonts buckets): Normal version numbers: X:\~projects\~powershell
λ (Get-ChildItem *\bucket\*.json -Recurse | % { (Get-Content $_ | ConvertFrom-Json).version } | ? { $_ -match "^[\d.]+$" }).Count
1181 Odd versions with other symbols then X:\~projects\~powershell
λ (Get-ChildItem *\bucket\*.json -Recurse | % { (Get-Content $_ | ConvertFrom-Json).version } | ? { $_ -notmatch "^[\d.]+$" }).Count
224 |
version
and compare_versions
compare_versions
-> Compare-Version
30e88d2
to
b82b884
Compare
…Version` Force install manifest version
compare_versions
-> Compare-Version
compare_versions
-> Compare-Version
@r15ch13 Please consider merge this PR, |
Could you add the following test ? (see shovel-org/Windows-JetBrains-Bucket#11)
|
fix #3329, fix #2981, fix #2720, fix ScoopInstaller/Extras#2106
Now force updating to manifest's version, despite installed version is greater or less than it.