3
3
. " ${PSScriptRoot} \SemVer.ps1"
4
4
5
5
$RELEASE_TITLE_REGEX = " (?<releaseNoteTitle>^\#+\s+(?<version>$ ( [AzureEngSemanticVersion ]::SEMVER_REGEX) )(\s+(?<releaseStatus>\(.+\))))"
6
- $SECTION_HEADER_REGEX_SUFFIX = " ## \s(?<sectionName>.*)"
6
+ $SECTIONS_HEADER_REGEX = " ^###+ \s(?<sectionName>.*)"
7
7
$CHANGELOG_UNRELEASED_STATUS = " (Unreleased)"
8
8
$CHANGELOG_DATE_FORMAT = " yyyy-MM-dd"
9
9
$RecommendedSectionHeaders = @ (" Features Added" , " Breaking Changes" , " Bugs Fixed" , " Other Changes" )
@@ -49,7 +49,6 @@ function Get-ChangeLogEntriesFromContent {
49
49
$initialAtxHeader = $matches [" HeaderLevel" ]
50
50
}
51
51
52
- $sectionHeaderRegex = " ^${initialAtxHeader}${SECTION_HEADER_REGEX_SUFFIX} "
53
52
$changeLogEntries | Add-Member - NotePropertyName " InitialAtxHeader" - NotePropertyValue $initialAtxHeader
54
53
$releaseTitleAtxHeader = $initialAtxHeader + " #"
55
54
@@ -68,7 +67,7 @@ function Get-ChangeLogEntriesFromContent {
68
67
}
69
68
else {
70
69
if ($changeLogEntry ) {
71
- if ($line.Trim () -match $sectionHeaderRegex )
70
+ if ($line.Trim () -match $SECTIONS_HEADER_REGEX )
72
71
{
73
72
$sectionName = $matches [" sectionName" ].Trim()
74
73
$changeLogEntry.Sections [$sectionName ] = @ ()
@@ -137,24 +136,16 @@ function Confirm-ChangeLogEntry {
137
136
[String ]$ChangeLogLocation ,
138
137
[Parameter (Mandatory = $true )]
139
138
[String ]$VersionString ,
140
- [boolean ]$ForRelease = $false ,
141
- [Switch ]$SantizeEntry
139
+ [boolean ]$ForRelease = $false
142
140
)
143
141
144
- $changeLogEntries = Get-ChangeLogEntries - ChangeLogLocation $ChangeLogLocation
145
- $changeLogEntry = $changeLogEntries [$VersionString ]
142
+ $changeLogEntry = Get-ChangeLogEntry - ChangeLogLocation $ChangeLogLocation - VersionString $VersionString
146
143
147
144
if (! $changeLogEntry ) {
148
145
LogError " ChangeLog[${ChangeLogLocation} ] does not have an entry for version ${VersionString} ."
149
146
return $false
150
147
}
151
148
152
- if ($SantizeEntry )
153
- {
154
- Remove-EmptySections - ChangeLogEntry $changeLogEntry - InitialAtxHeader $changeLogEntries.InitialAtxHeader
155
- Set-ChangeLogContent - ChangeLogLocation $ChangeLogLocation - ChangeLogEntries $changeLogEntries
156
- }
157
-
158
149
Write-Host " Found the following change log entry for version '${VersionString} ' in [${ChangeLogLocation} ]."
159
150
Write-Host " -----"
160
151
Write-Host (ChangeLogEntryAsString $changeLogEntry )
@@ -317,26 +308,24 @@ function Set-ChangeLogContent {
317
308
function Remove-EmptySections {
318
309
param (
319
310
[Parameter (Mandatory = $true )]
320
- $ChangeLogEntry ,
321
- $InitialAtxHeader = " #"
311
+ $ChangeLogEntry
322
312
)
323
313
324
- $sectionHeaderRegex = " ^${InitialAtxHeader}${SECTION_HEADER_REGEX_SUFFIX} "
325
314
$releaseContent = $ChangeLogEntry.ReleaseContent
326
315
327
316
if ($releaseContent.Count -gt 0 )
328
317
{
329
318
$parsedSections = $ChangeLogEntry.Sections
330
319
$sanitizedReleaseContent = New-Object System.Collections.ArrayList(, $releaseContent )
331
320
332
- foreach ($key in @ ($parsedSections.Keys ))
321
+ foreach ($key in @ ($parsedSections.Key ))
333
322
{
334
323
if ([System.String ]::IsNullOrWhiteSpace($parsedSections [$key ]))
335
324
{
336
325
for ($i = 0 ; $i -lt $sanitizedReleaseContent.Count ; $i ++ )
337
326
{
338
327
$line = $sanitizedReleaseContent [$i ]
339
- if ($line -match $sectionHeaderRegex -and $matches [" sectionName" ].Trim() -eq $key )
328
+ if ($line -match $SECTIONS_HEADER_REGEX -and $matches [" sectionName" ].Trim() -eq $key )
340
329
{
341
330
$sanitizedReleaseContent.RemoveAt ($i )
342
331
while ($i -lt $sanitizedReleaseContent.Count -and [System.String ]::IsNullOrWhiteSpace($sanitizedReleaseContent [$i ]))
@@ -351,4 +340,5 @@ function Remove-EmptySections {
351
340
}
352
341
$ChangeLogEntry.ReleaseContent = $sanitizedReleaseContent.ToArray ()
353
342
}
354
- }
343
+ return $changeLogEntry
344
+ }
0 commit comments