Skip to content

Commit

Permalink
Update semver and Changelog logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu authored and azure-sdk committed Jan 25, 2021
1 parent bf60d74 commit d47dbcc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
33 changes: 11 additions & 22 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
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 Expand Up @@ -191,7 +191,16 @@ function Set-ChangeLogContent {
$changeLogContent += "# Release History"
$changeLogContent += ""

foreach ($version in $ChangeLogEntries.Keys) {
try
{
$VersionsSorted = [AzureEngSemanticVersion]::SortVersionStrings($ChangeLogEntries.Keys)
}
catch {
LogError "Problem sorting version in ChangeLogEntries"
return
}

foreach ($version in $VersionsSorted) {
$changeLogEntry = $ChangeLogEntries[$version]
$changeLogContent += $changeLogEntry.ReleaseTitle
if ($changeLogEntry.ReleaseContent.Count -eq 0) {
Expand All @@ -203,24 +212,4 @@ function Set-ChangeLogContent {
}

Set-Content -Path $ChangeLogLocation -Value $changeLogContent
}

function Add-ChangelogEntry {
param (
[Parameter(Mandatory = $true)]
$ChangeLogEntries,
[Parameter(Mandatory = $true)]
$NewChangeLogEntry,
[Parameter(Mandatory = $true)]
$Version
)

$results = [Ordered]@{}
$results.Add($Version, $NewChangeLogEntry)

foreach ($entryVersion in $ChangeLogEntries.Keys) {
$results.Add($entryVersion, $ChangeLogEntries[$entryVersion])
}

return $results
}
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
14 changes: 5 additions & 9 deletions eng/common/scripts/Update-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ if ($ChangeLogEntries.Contains($Version))
}
}

$LatestVersion = $ChangeLogEntries[0].ReleaseVersion
$PresentVersionsSorted = [AzureEngSemanticVersion]::SortVersionStrings($ChangeLogEntries.Keys)
$LatestVersion = $PresentVersionsSorted[0]

LogDebug "The latest release note entry in the changelog is for version [$($LatestVersion)]"

$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 @@ -98,9 +98,7 @@ if ($ReplaceLatestEntryTitle)
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"
$ChangeLogEntries.Remove($LatestVersion)
if ($newChangeLogEntry) {
$ChangeLogEntries = Add-ChangelogEntry -ChangeLogEntries $ChangeLogEntries `
-NewChangeLogEntry $newChangeLogEntry `
-Version $Version
$ChangeLogEntries.Insert(0, $Version, $newChangeLogEntry)
}
else {
LogError "Failed to create new changelog entry"
Expand All @@ -118,9 +116,7 @@ else
LogDebug "Adding new ChangeLog entry for Version [$Version]"
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus
if ($newChangeLogEntry) {
$ChangeLogEntries = Add-ChangelogEntry -ChangeLogEntries $ChangeLogEntries `
-NewChangeLogEntry $newChangeLogEntry `
-Version $Version
$ChangeLogEntries.Insert(0, $Version, $newChangeLogEntry)
}
else {
LogError "Failed to create new changelog entry"
Expand Down

0 comments on commit d47dbcc

Please sign in to comment.