From 0c0d1cd8c19c39e4cd321ad946b21aca5f73a8a2 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Tue, 9 Jan 2024 13:57:02 -0600 Subject: [PATCH] (mkdocs-material) Add case for dependency versioning change --- automatic/mkdocs-material/update.ps1 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/automatic/mkdocs-material/update.ps1 b/automatic/mkdocs-material/update.ps1 index 9d2eff45cad..de8413f8230 100644 --- a/automatic/mkdocs-material/update.ps1 +++ b/automatic/mkdocs-material/update.ps1 @@ -22,9 +22,24 @@ function global:au_GetLatest { $download_page = Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/squidfunk/mkdocs-material/raw/${version}/requirements.txt" if ($download_page.content -match "mkdocs>=(\d+\.[\d\.]+)") { - $dependencyVersion = $matches[1] + $dependencyVersion = $matches[1] + } elseif ($download_page.content -match "mkdocs~=(\d+\.[\d\.]+)") { + # Case for compatible version syntax. + $minimumVersion = $matches[1] + [int]$majorVersion = $minimumVersion -split "\." | Select-Object -First 1 + $minimumVersionParts = ($minimumVersion -split "\.").count + if ($minimumVersionParts -eq 2) { + $nextMajorVersion = $majorVersion + 1 + $dependencyVersion = "[$minimumVersion,$nextMajorVersion.0.0)" + } elseif ($minimumVersionParts -eq 3) { + [int]$minorVersion = $minimumVersion -split "\." | Select-Object -First 1 -Skip 1 + $nextMinorVersion = $minorVersion + 1 + $dependencyVersion = "[$minimumVersion,$majorVersion.$nextMinorVersion.0)" + } else { + throw "Invalid number of minimum version parts '$minimumVersionParts'" + } } else { - throw "Mkdocs dependency version was not found" + throw "Mkdocs dependency version was not found" } return @{ Version = $version; MkDocsDep = $dependencyVersion }