Add Get-ChangeLogEntriesFromContent (#2345)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-05-25 20:03:58 -04:00 committed by GitHub
parent 73d5ba0d2d
commit 55cd432693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"]
@ -41,7 +59,7 @@ function Get-ChangeLogEntries {
}
}
catch {
Write-Host "Error parsing $ChangeLogLocation."
Write-Host "Error parsing Changelog."
Write-Host $_.Exception.Message
}
return $changeLogEntries