Skip to content

Commit

Permalink
Add parsing of changelog sections
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jun 3, 2021
1 parent 62572bb commit 9f63951
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,45 @@ function Get-ChangeLogEntriesFromContent {
$changeLogEntries = [Ordered]@{}
try {
# walk the document, finding where the version specifiers are and creating lists
$changeLogEntry = $null
foreach ($line in $changeLogContent) {
if ($line -match $RELEASE_TITLE_REGEX) {
$changeLogEntry = [pscustomobject]@{
ReleaseVersion = $matches["version"]
ReleaseStatus = $matches["releaseStatus"]
ReleaseTitle = "## {0} {1}" -f $matches["version"], $matches["releaseStatus"]
ReleaseContent = @()
FeaturesAdded = @()
BreakingChanges = @()
KeyBugsFixed = @()
Fixed = @()
}
$changeLogEntries[$changeLogEntry.ReleaseVersion] = $changeLogEntry
}
else {
if ($changeLogEntry) {
if ($line.Trim() -match "###\s(?<sectionName>.*)")
{
$sectionName = $matches["sectionName"]
$changeLogEntry.ReleaseContent += $line
continue
}

if (-not [System.String]::IsNullOrEmpty($line))
{
switch ($sectionName)
{
"Features Added" { $changeLogEntry.FeaturesAdded += $line }
"Breaking Changes" { $changeLogEntry.BreakingChanges += $line }
"Key Bugs Fixed" { $changeLogEntry.KeyBugsFixed += $line }
"Fixed" { $changeLogEntry.Fixed += $line }
}
}

$changeLogEntry.ReleaseContent += $line
}
}
}
}
catch {
Write-Host "Error parsing Changelog."
Write-Host $_.Exception.Message
}
return $changeLogEntries
}

Expand Down

0 comments on commit 9f63951

Please sign in to comment.