Update changelog parsing to round-trip header (#6710)

Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
This commit is contained in:
Azure SDK Bot 2025-08-22 14:25:43 -07:00 committed by GitHub
parent 7a5f1a869e
commit 567f0b61ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,6 +52,7 @@ function Get-ChangeLogEntriesFromContent {
$sectionHeaderRegex = "^${initialAtxHeader}${SECTION_HEADER_REGEX_SUFFIX}"
$changeLogEntries | Add-Member -NotePropertyName "InitialAtxHeader" -NotePropertyValue $initialAtxHeader
$releaseTitleAtxHeader = $initialAtxHeader + "#"
$headerLines = @()
try {
# walk the document, finding where the version specifiers are and creating lists
@ -83,6 +84,9 @@ function Get-ChangeLogEntriesFromContent {
$changeLogEntry.ReleaseContent += $line
}
else {
$headerLines += $line
}
}
}
}
@ -90,6 +94,8 @@ function Get-ChangeLogEntriesFromContent {
Write-Error "Error parsing Changelog."
Write-Error $_
}
$changeLogEntries | Add-Member -NotePropertyName "HeaderBlock" -NotePropertyValue ($headerLines -Join [Environment]::NewLine)
return $changeLogEntries
}
@ -265,8 +271,13 @@ function Set-ChangeLogContent {
)
$changeLogContent = @()
$changeLogContent += "$($ChangeLogEntries.InitialAtxHeader) Release History"
$changeLogContent += ""
if ($ChangeLogEntries.HeaderBlock) {
$changeLogContent += $ChangeLogEntries.HeaderBlock
}
else {
$changeLogContent += "$($ChangeLogEntries.InitialAtxHeader) Release History"
$changeLogContent += ""
}
$ChangeLogEntries = Sort-ChangeLogEntries -changeLogEntries $ChangeLogEntries