Strict mode needs the variables initialized (#2443)

Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-06-09 18:48:16 -07:00 committed by GitHub
parent 479134595b
commit d5d585500d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -37,12 +37,14 @@ function Get-ChangeLogEntriesFromContent {
return $null
}
$changelogEntry = $null
$sectionName = $null
$changeLogEntries = [Ordered]@{}
try {
# walk the document, finding where the version specifiers are and creating lists
foreach ($line in $changeLogContent) {
if ($line -match $RELEASE_TITLE_REGEX) {
$changeLogEntry = [pscustomobject]@{
$changeLogEntry = [pscustomobject]@{
ReleaseVersion = $matches["version"]
ReleaseStatus = $matches["releaseStatus"]
ReleaseTitle = "## {0} {1}" -f $matches["version"], $matches["releaseStatus"]
@ -72,8 +74,8 @@ function Get-ChangeLogEntriesFromContent {
}
}
catch {
Write-Host "Error parsing Changelog."
Write-Host $_.Exception.Message
Write-Error "Error parsing Changelog."
Write-Error $_
}
return $changeLogEntries
}
@ -208,7 +210,7 @@ function New-ChangeLogEntry {
return $null
}
if (!$Content) {
if (!$Content) {
$Content = @()
$Content += ""
$Content += "### Features Added"
@ -222,7 +224,7 @@ function New-ChangeLogEntry {
$Content += ""
}
$newChangeLogEntry = [pscustomobject]@{
$newChangeLogEntry = [pscustomobject]@{
ReleaseVersion = $Version
ReleaseStatus = $Status
ReleaseTitle = "## $Version $Status"

View File

@ -15,6 +15,7 @@ param (
[String]$ChangelogPath,
[String]$ReleaseDate
)
Set-StrictMode -Version 3
. (Join-Path $PSScriptRoot common.ps1)
@ -39,11 +40,11 @@ if ($ReleaseDate)
exit 1
}
}
elseif ($Unreleased)
elseif ($Unreleased)
{
$ReleaseStatus = $CHANGELOG_UNRELEASED_STATUS
}
else
else
{
$ReleaseStatus = "$(Get-Date -Format $CHANGELOG_DATE_FORMAT)"
$ReleaseStatus = "($ReleaseStatus)"
@ -61,7 +62,7 @@ if ([string]::IsNullOrEmpty($ChangelogPath))
$ChangelogPath = $pkgProperties.ChangeLogPath
}
if (!(Test-Path $ChangelogPath))
if (!(Test-Path $ChangelogPath))
{
LogError "Changelog path [$ChangelogPath] is invalid."
exit 1
@ -103,7 +104,7 @@ if ($LatestsSorted[0] -ne $Version) {
LogWarning "Version [$Version] is older than the latestversion [$LatestVersion] in the changelog. Consider using a more recent version."
}
if ($ReplaceLatestEntryTitle)
if ($ReplaceLatestEntryTitle)
{
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $ChangeLogEntries[$LatestVersion].ReleaseContent
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"

View File

@ -6,11 +6,12 @@ param (
[string]$ServiceDirectory,
[boolean]$ForRelease = $False
)
Set-StrictMode -Version 3
. (Join-Path $PSScriptRoot common.ps1)
$validChangeLog = $false
if ($ChangeLogLocation -and $VersionString)
if ($ChangeLogLocation -and $VersionString)
{
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $ChangeLogLocation -VersionString $VersionString -ForRelease $ForRelease
}