From cdb5fbfb3576f4a2337af738b0604317ebe7142c Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 3 May 2021 10:27:04 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 1524 (#2179) * Make RELEASE_TITLE_REGEX more specific * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Wes Haggard * Update release REGEX * tighten up changelog verification * Ensure releaseDate is in the appriopriate format. * Update error messages. * Retrun false after error Co-authored-by: Chidozie Ononiwu Co-authored-by: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com> Co-authored-by: Wes Haggard --- eng/common/scripts/ChangeLog-Operations.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/ChangeLog-Operations.ps1 b/eng/common/scripts/ChangeLog-Operations.ps1 index 0f02790ce..8547791af 100644 --- a/eng/common/scripts/ChangeLog-Operations.ps1 +++ b/eng/common/scripts/ChangeLog-Operations.ps1 @@ -2,7 +2,7 @@ . "${PSScriptRoot}\logging.ps1" . "${PSScriptRoot}\SemVer.ps1" -$RELEASE_TITLE_REGEX = "(?^\#+.*(?\b\d+\.\d+\.\d+([^0-9\s][^\s:]+)?)(\s+(?\(.*\)))?)" +$RELEASE_TITLE_REGEX = "(?^\#+\s+(?$([AzureEngSemanticVersion]::SEMVER_REGEX))(\s+(?\(.+\))))" $CHANGELOG_UNRELEASED_STATUS = "(Unreleased)" $CHANGELOG_DATE_FORMAT = "yyyy-MM-dd" @@ -120,7 +120,17 @@ function Confirm-ChangeLogEntry { else { $status = $changeLogEntry.ReleaseStatus.Trim().Trim("()") try { - [DateTime]$status + $releaseDate = [DateTime]$status + if ($status -ne ($releaseDate.ToString($CHANGELOG_DATE_FORMAT))) + { + LogError "Date must be in the format $($CHANGELOG_DATE_FORMAT)" + return $false + } + if (((Get-Date).AddMonths(-1) -gt $releaseDate) -or ($releaseDate -gt (Get-Date).AddMonths(1))) + { + LogError "The date must be within +/- one month from today." + return $false + } } catch { LogError "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]." @@ -212,4 +222,4 @@ function Set-ChangeLogContent { } Set-Content -Path $ChangeLogLocation -Value $changeLogContent -} \ No newline at end of file +}