Skip to content

Commit 682b4a8

Browse files
Update changelog parsing to round-trip header (#42649)
Co-authored-by: Wes Haggard <[email protected]>
1 parent 8df21a0 commit 682b4a8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function Get-ChangeLogEntriesFromContent {
5252
$sectionHeaderRegex = "^${initialAtxHeader}${SECTION_HEADER_REGEX_SUFFIX}"
5353
$changeLogEntries | Add-Member -NotePropertyName "InitialAtxHeader" -NotePropertyValue $initialAtxHeader
5454
$releaseTitleAtxHeader = $initialAtxHeader + "#"
55+
$headerLines = @()
5556

5657
try {
5758
# walk the document, finding where the version specifiers are and creating lists
@@ -83,13 +84,18 @@ function Get-ChangeLogEntriesFromContent {
8384

8485
$changeLogEntry.ReleaseContent += $line
8586
}
87+
else {
88+
$headerLines += $line
89+
}
8690
}
8791
}
8892
}
8993
catch {
9094
Write-Error "Error parsing Changelog."
9195
Write-Error $_
9296
}
97+
98+
$changeLogEntries | Add-Member -NotePropertyName "HeaderBlock" -NotePropertyValue ($headerLines -Join [Environment]::NewLine)
9399
return $changeLogEntries
94100
}
95101

@@ -265,8 +271,13 @@ function Set-ChangeLogContent {
265271
)
266272

267273
$changeLogContent = @()
268-
$changeLogContent += "$($ChangeLogEntries.InitialAtxHeader) Release History"
269-
$changeLogContent += ""
274+
if ($ChangeLogEntries.HeaderBlock) {
275+
$changeLogContent += $ChangeLogEntries.HeaderBlock
276+
}
277+
else {
278+
$changeLogContent += "$($ChangeLogEntries.InitialAtxHeader) Release History"
279+
$changeLogContent += ""
280+
}
270281

271282
$ChangeLogEntries = Sort-ChangeLogEntries -changeLogEntries $ChangeLogEntries
272283

0 commit comments

Comments
 (0)