Skip to content

Commit

Permalink
Add Get-ChangeLogEntriesFromContent
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu authored and azure-sdk committed May 25, 2021
1 parent e82661b commit cd42fa7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,35 @@ function Get-ChangeLogEntries {
[String]$ChangeLogLocation
)

$changeLogEntries = [Ordered]@{}
if (!(Test-Path $ChangeLogLocation)) {
LogError "ChangeLog[${ChangeLogLocation}] does not exist"
return $null
}
LogDebug "Extracting entries from [${ChangeLogLocation}]."
return Get-ChangeLogEntriesFromContent (Get-Content -Path $ChangeLogLocation)
}

function Get-ChangeLogEntriesFromContent {
param (
[Parameter(Mandatory = $true)]
$changeLogContent
)

if ($changeLogContent -is [string])
{
$changeLogContent = $changeLogContent.Split("`n")
}
elseif($changeLogContent -isnot [array])
{
LogError "Invalid ChangelogContent passed"
return $null
}

$changeLogEntries = [Ordered]@{}
try {
$contents = Get-Content $ChangeLogLocation
# walk the document, finding where the version specifiers are and creating lists
$changeLogEntry = $null
foreach ($line in $contents) {
foreach ($line in $changeLogContent) {
if ($line -match $RELEASE_TITLE_REGEX) {
$changeLogEntry = [pscustomobject]@{
ReleaseVersion = $matches["version"]
Expand All @@ -41,7 +59,7 @@ function Get-ChangeLogEntries {
}
}
catch {
Write-Host "Error parsing $ChangeLogLocation."
Write-Host "Error parsing Changelog."
Write-Host $_.Exception.Message
}
return $changeLogEntries
Expand Down

0 comments on commit cd42fa7

Please sign in to comment.