Sort changelogs by date then version (#1479)

Fixes #1389
This commit is contained in:
Heath Stewart 2021-03-10 11:59:22 -08:00 коммит произвёл GitHub
Родитель 0a0b8724f3
Коммит f1c5a2ab67
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 29 добавлений и 8 удалений

Просмотреть файл

@ -193,15 +193,14 @@ function Set-ChangeLogContent {
try
{
$VersionsSorted = [AzureEngSemanticVersion]::SortVersionStrings($ChangeLogEntries.Keys)
$ChangeLogEntries = $ChangeLogEntries.Values | Sort-Object -Descending -Property ReleaseStatus, ReleaseVersion
}
catch {
LogError "Problem sorting version in ChangeLogEntries"
return
}
foreach ($version in $VersionsSorted) {
$changeLogEntry = $ChangeLogEntries[$version]
foreach ($changeLogEntry in $ChangeLogEntries) {
$changeLogContent += $changeLogEntry.ReleaseTitle
if ($changeLogEntry.ReleaseContent.Count -eq 0) {
$changeLogContent += @("","")

Просмотреть файл

@ -13,7 +13,7 @@ Components: Major.Minor.Patch-PrereleaseLabel.PrereleaseNumber.BuildNumber
Note: A builtin Powershell version of SemVer exists in 'System.Management.Automation'. At this time, it does not parsing of PrereleaseNumber. It's name is also type accelerated to 'SemVer'.
#>
class AzureEngSemanticVersion {
class AzureEngSemanticVersion : IComparable {
[int] $Major
[int] $Minor
[int] $Patch
@ -178,6 +178,31 @@ class AzureEngSemanticVersion {
$this.DefaultAlphaReleaseLabel = "alpha"
}
[int] CompareTo($other)
{
if ($other -isnot [AzureEngSemanticVersion]) {
throw "Cannot compare $other with $this"
}
$ret = $this.Major.CompareTo($other.Major)
if ($ret) { return $ret }
$ret = $this.Minor.CompareTo($other.Minor)
if ($ret) { return $ret }
$ret = $this.Patch.CompareTo($other.Patch)
if ($ret) { return $ret }
# Mimic PowerShell that uses case-insensitive comparisons by default.
$ret = [string]::Compare($this.PrereleaseLabel, $other.PrereleaseLabel, $true)
if ($ret) { return $ret }
$ret = $this.PrereleaseNumber.CompareTo($other.PrereleaseNumber)
if ($ret) { return $ret }
return ([int] $this.BuildNumber).CompareTo([int] $other.BuildNumber)
}
static [string[]] SortVersionStrings([string[]] $versionStrings)
{
$versions = $versionStrings | ForEach-Object { [AzureEngSemanticVersion]::ParseVersionString($_) }
@ -187,10 +212,7 @@ class AzureEngSemanticVersion {
static [AzureEngSemanticVersion[]] SortVersions([AzureEngSemanticVersion[]] $versions)
{
return ($versions | `
Sort-Object -Descending -Property `
Major, Minor, Patch, PrereleaseLabel, PrereleaseNumber, `
@{ Expression = { [int]$_.BuildNumber }; Descending = $true })
return $versions | Sort-Object -Descending
}
static [void] QuickTests()