Sync eng/common directory with azure-sdk-tools for PR 1335 (#1441)

* Lossen up $RELEASE_TITLE_REGEX to accomodate wrongly formated changelogs

* Update changelog logic to use ordered hashtable

* Update semver and Changelog logic

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-01-25 10:50:56 -08:00 committed by GitHub
parent d2f29afb1d
commit 469bf2ca2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View File

@ -2,7 +2,7 @@
. "${PSScriptRoot}\logging.ps1"
. "${PSScriptRoot}\SemVer.ps1"
$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+.*(?<version>\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s+(?<releaseStatus>\(Unreleased\)|\(\d{4}-\d{2}-\d{2}\)))?)"
$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+.*(?<version>\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s+(?<releaseStatus>\(.*\)))?)"
$CHANGELOG_UNRELEASED_STATUS = "(Unreleased)"
$CHANGELOG_DATE_FORMAT = "yyyy-MM-dd"
@ -13,7 +13,7 @@ function Get-ChangeLogEntries {
[String]$ChangeLogLocation
)
$changeLogEntries = @{}
$changeLogEntries = [Ordered]@{}
if (!(Test-Path $ChangeLogLocation)) {
LogError "ChangeLog[${ChangeLogLocation}] does not exist"
return $null
@ -57,7 +57,7 @@ function Get-ChangeLogEntry {
)
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
if ($changeLogEntries -and $changeLogEntries.ContainsKey($VersionString)) {
if ($changeLogEntries -and $changeLogEntries.Contains($VersionString)) {
return $changeLogEntries[$VersionString]
}
return $null

View File

@ -181,7 +181,7 @@ class AzureEngSemanticVersion {
{
$versions = $versionStrings | ForEach-Object { [AzureEngSemanticVersion]::ParseVersionString($_) }
$sortedVersions = [AzureEngSemanticVersion]::SortVersions($versions)
return ($sortedVersions | ForEach-Object { $_.ToString() })
return ($sortedVersions | ForEach-Object { $_.RawVersion })
}
static [AzureEngSemanticVersion[]] SortVersions([AzureEngSemanticVersion[]] $versions)

View File

@ -89,8 +89,7 @@ LogDebug "The latest release note entry in the changelog is for version [$($Late
$LatestsSorted = [AzureEngSemanticVersion]::SortVersionStrings(@($LatestVersion, $Version))
if ($LatestsSorted[0] -ne $Version) {
LogWarning "Version [$Version] is older than the latestversion [$LatestVersion] in the changelog. Please use a more recent version."
exit(0)
LogWarning "Version [$Version] is older than the latestversion [$LatestVersion] in the changelog. Consider using a more recent version."
}
if ($ReplaceLatestEntryTitle)
@ -99,7 +98,7 @@ if ($ReplaceLatestEntryTitle)
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"
$ChangeLogEntries.Remove($LatestVersion)
if ($newChangeLogEntry) {
$ChangeLogEntries[$Version] = $newChangeLogEntry
$ChangeLogEntries.Insert(0, $Version, $newChangeLogEntry)
}
else {
LogError "Failed to create new changelog entry"
@ -117,7 +116,7 @@ else
LogDebug "Adding new ChangeLog entry for Version [$Version]"
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus
if ($newChangeLogEntry) {
$ChangeLogEntries[$Version] = $newChangeLogEntry
$ChangeLogEntries.Insert(0, $Version, $newChangeLogEntry)
}
else {
LogError "Failed to create new changelog entry"