Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1335 (#16311)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
azure-sdk and chidozieononiwu authored Jan 25, 2021
1 parent d50442b commit bb49488
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -13,7 +13,7 @@ function Get-ChangeLogEntries {
[String]$ChangeLogLocation
)

$changeLogEntries = @{}
$changeLogEntries = [Ordered]@{}
if (!(Test-Path $ChangeLogLocation)) {
LogError "ChangeLog[${ChangeLogLocation}] does not exist"
return $null
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/SemVer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions eng/common/scripts/Update-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit bb49488

Please sign in to comment.