33. " ${PSScriptRoot} \SemVer.ps1"
44
55$RELEASE_TITLE_REGEX = " (?<releaseNoteTitle>^\#+\s+(?<version>$ ( [AzureEngSemanticVersion ]::SEMVER_REGEX) )(\s+(?<releaseStatus>\(.+\))))"
6- $SECTIONS_HEADER_REGEX = " ^###\s(?<sectionName>.*)"
6+ $SECTIONS_HEADER_REGEX = " ^###+ \s(?<sectionName>.*)"
77$CHANGELOG_UNRELEASED_STATUS = " (Unreleased)"
88$CHANGELOG_DATE_FORMAT = " yyyy-MM-dd"
99$RecommendedSectionHeaders = @ (" Features Added" , " Breaking Changes" , " Bugs Fixed" , " Other Changes" )
@@ -42,14 +42,24 @@ function Get-ChangeLogEntriesFromContent {
4242 $changelogEntry = $null
4343 $sectionName = $null
4444 $changeLogEntries = [Ordered ]@ {}
45+ $initialAtxHeader = " #"
46+
47+ if ($changeLogContent [0 ] -match " (?<HeaderLevel>^#+)\s.*" )
48+ {
49+ $initialAtxHeader = $matches [" HeaderLevel" ]
50+ }
51+
52+ $changeLogEntries | Add-Member - NotePropertyName " InitialAtxHeader" - NotePropertyValue $initialAtxHeader
53+ $releaseTitleAtxHeader = $initialAtxHeader + " #"
54+
4555 try {
4656 # walk the document, finding where the version specifiers are and creating lists
4757 foreach ($line in $changeLogContent ) {
4858 if ($line -match $RELEASE_TITLE_REGEX ) {
4959 $changeLogEntry = [pscustomobject ]@ {
5060 ReleaseVersion = $matches [" version" ]
5161 ReleaseStatus = $matches [" releaseStatus" ]
52- ReleaseTitle = " ## {0} {1}" -f $matches [" version" ], $matches [" releaseStatus" ]
62+ ReleaseTitle = " $releaseTitleAtxHeader {0} {1}" -f $matches [" version" ], $matches [" releaseStatus" ]
5363 ReleaseContent = @ ()
5464 Sections = @ {}
5565 }
@@ -210,6 +220,7 @@ function New-ChangeLogEntry {
210220 [ValidateNotNullOrEmpty ()]
211221 [String ]$Version ,
212222 [String ]$Status = $CHANGELOG_UNRELEASED_STATUS ,
223+ [String ]$InitialAtxHeader = " #" ,
213224 [String []]$Content
214225 )
215226
@@ -239,17 +250,20 @@ function New-ChangeLogEntry {
239250 $Content = @ ()
240251 $Content += " "
241252
253+ $sectionsAtxHeader = $InitialAtxHeader + " ##"
242254 foreach ($recommendedHeader in $RecommendedSectionHeaders )
243255 {
244- $Content += " ### $recommendedHeader "
256+ $Content += " $sectionsAtxHeader $recommendedHeader "
245257 $Content += " "
246258 }
247259 }
248260
261+ $releaseTitleAtxHeader = $initialAtxHeader + " #"
262+
249263 $newChangeLogEntry = [pscustomobject ]@ {
250264 ReleaseVersion = $Version
251265 ReleaseStatus = $Status
252- ReleaseTitle = " ## $Version $Status "
266+ ReleaseTitle = " $releaseTitleAtxHeader $Version $Status "
253267 ReleaseContent = $Content
254268 }
255269
@@ -265,7 +279,7 @@ function Set-ChangeLogContent {
265279 )
266280
267281 $changeLogContent = @ ()
268- $changeLogContent += " # Release History"
282+ $changeLogContent += " $ ( $ChangeLogEntries .InitialAtxHeader ) Release History"
269283 $changeLogContent += " "
270284
271285 try
@@ -298,7 +312,6 @@ function Remove-EmptySections {
298312 )
299313
300314 $releaseContent = $ChangeLogEntry.ReleaseContent
301- $sectionsToRemove = @ ()
302315
303316 if ($releaseContent.Count -gt 0 )
304317 {
0 commit comments