Skip to content

Commit

Permalink
(universal-usb-installer) Treat trailing character as a additional ve…
Browse files Browse the repository at this point in the history
…rsion number

This commit updates the automatic updater to treat any trailing character
as its own number to be appended to the last version part, this allows us to
create a new package version even when the software developer has created
a new version without using a pure version number.

ref chocolatey-community#2187
  • Loading branch information
AdmiringWorm committed Mar 27, 2023
1 parent 533b518 commit 1983ffd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions automatic/universal-usb-installer/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ function global:au_SearchReplace {
}
}
}

function Convert-CharacterToNumber {
param(
[Parameter(Mandatory)]
[char] $character
)

$newNum = ([int]$character) + 1

$newNum - [int]([char]'a')
}

function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing

Expand All @@ -27,6 +39,13 @@ function global:au_GetLatest {

$verRe = '[-]|\.exe$'
$version32 = $url32 -split "$verRe" | Select-Object -Last 1 -Skip 1

if ($version32 -match "^([\d\.]+)([a-z])$") {
$m1 = $Matches[1]
$num = Convert-CharacterToNumber $Matches[2]
$version32 = "${m1}$num"
}

@{
URL32 = $url32
Version = Get-FixVersion $version32 -OnlyFixBelowVersion $padVersionUnder
Expand Down

0 comments on commit 1983ffd

Please sign in to comment.