Skip to content

Commit

Permalink
Strict mode needs the variables initialized (#1779)
Browse files Browse the repository at this point in the history
Co-authored-by: Wes Haggard <[email protected]>
  • Loading branch information
azure-sdk and weshaggard authored Jun 10, 2021
1 parent ab1a40c commit 0c92d2c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -208,7 +210,7 @@ function New-ChangeLogEntry {
return $null
}

if (!$Content) {
if (!$Content) {
$Content = @()
$Content += ""
$Content += "### Features Added"
Expand All @@ -222,7 +224,7 @@ function New-ChangeLogEntry {
$Content += ""
}

$newChangeLogEntry = [pscustomobject]@{
$newChangeLogEntry = [pscustomobject]@{
ReleaseVersion = $Version
ReleaseStatus = $Status
ReleaseTitle = "## $Version $Status"
Expand Down
9 changes: 5 additions & 4 deletions eng/common/scripts/Update-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ param (
[String]$ChangelogPath,
[String]$ReleaseDate
)
Set-StrictMode -Version 3

. (Join-Path $PSScriptRoot common.ps1)

Expand All @@ -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)"
Expand All @@ -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
Expand Down Expand Up @@ -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)]"
Expand Down
3 changes: 2 additions & 1 deletion eng/common/scripts/Verify-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0c92d2c

Please sign in to comment.