Skip to content

Commit 3fd59f3

Browse files
azure-sdkchidozieononiwubenbp
authored
Sync eng/common directory with azure-sdk-tools for PR 2836 (Azure#20635)
* Verify changelog like a release is about to take place if a vlaid date is present * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com> Co-authored-by: Chidozie Ononiwu (His Righteousness) <31145988+chidozieononiwu@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
1 parent bae6ad5 commit 3fd59f3

File tree

1 file changed

+76
-53
lines changed

1 file changed

+76
-53
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 76 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -165,61 +165,20 @@ function Confirm-ChangeLogEntry {
165165
return $false
166166
}
167167

168-
if ($ForRelease -eq $True) {
169-
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
170-
LogError "Entry has no release date set. Please ensure to set a release date with format '$CHANGELOG_DATE_FORMAT'. See https://aka.ms/azsdk/guideline/changelogs for more info."
171-
return $false
172-
}
173-
else {
174-
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
175-
try {
176-
$releaseDate = [DateTime]$status
177-
if ($status -ne ($releaseDate.ToString($CHANGELOG_DATE_FORMAT)))
178-
{
179-
LogError "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
180-
return $false
181-
}
182-
if (((Get-Date).AddMonths(-1) -gt $releaseDate) -or ($releaseDate -gt (Get-Date).AddMonths(1)))
183-
{
184-
LogError "The date must be within +/- one month from today. See https://aka.ms/azsdk/guideline/changelogs for more info."
185-
return $false
186-
}
187-
}
188-
catch {
189-
LogError "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
190-
return $false
191-
}
192-
}
193-
194-
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
195-
LogError "Entry has no content. Please ensure to provide some content of what changed in this version. See https://aka.ms/azsdk/guideline/changelogs for more info."
196-
return $false
197-
}
168+
if ($ForRelease -eq $True)
169+
{
170+
LogDebug "Verifying like it's a release build because ForRelease parameter is set to true"
171+
return Confirm-LikeForRelease -changeLogEntry $changeLogEntry
172+
}
198173

199-
$foundRecomendedSection = $false
200-
$emptySections = @()
201-
foreach ($key in $changeLogEntry.Sections.Keys)
202-
{
203-
$sectionContent = $changeLogEntry.Sections[$key]
204-
if ([System.String]::IsNullOrWhiteSpace(($sectionContent | Out-String)))
205-
{
206-
$emptySections += $key
207-
}
208-
if ($RecommendedSectionHeaders -contains $key)
209-
{
210-
$foundRecomendedSection = $true
211-
}
212-
}
213-
if ($emptySections.Count -gt 0)
214-
{
215-
LogError "The changelog entry has the following sections with no content ($($emptySections -join ', ')). Please ensure to either remove the empty sections or add content to the section."
216-
return $false
217-
}
218-
if (!$foundRecomendedSection)
219-
{
220-
LogWarning "The changelog entry did not contain any of the recommended sections ($($RecommendedSectionHeaders -join ', ')), pease add at least one. See https://aka.ms/azsdk/guideline/changelogs for more info."
221-
}
174+
# If the release status is a valid date then verify like its about to be released
175+
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
176+
if ($status -as [DateTime])
177+
{
178+
LogDebug "Verifying like it's a release build because the changelog entry has a valid date."
179+
return Confirm-LikeForRelease -changeLogEntry $changeLogEntry
222180
}
181+
223182
return $true
224183
}
225184

@@ -362,4 +321,68 @@ function Get-LatestReleaseDateFromChangeLog
362321
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
363322
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
364323
return ($latestVersion -as [DateTime])
324+
}
325+
326+
function Confirm-LikeForRelease {
327+
param (
328+
[Parameter(Mandatory = $true)]
329+
$changeLogEntry
330+
)
331+
332+
$isValid = $true
333+
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
334+
LogError "Entry has no release date set. Please ensure to set a release date with format '$CHANGELOG_DATE_FORMAT'. See https://aka.ms/azsdk/guideline/changelogs for more info."
335+
$isValid = $false
336+
}
337+
else {
338+
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
339+
try {
340+
$releaseDate = [DateTime]$status
341+
if ($status -ne ($releaseDate.ToString($CHANGELOG_DATE_FORMAT)))
342+
{
343+
LogError "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
344+
$isValid = $false
345+
}
346+
if (((Get-Date).AddMonths(-1) -gt $releaseDate) -or ($releaseDate -gt (Get-Date).AddMonths(1)))
347+
{
348+
LogError "The date must be within +/- one month from today. See https://aka.ms/azsdk/guideline/changelogs for more info."
349+
$isValid = $false
350+
}
351+
}
352+
catch {
353+
LogError "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
354+
$isValid = $false
355+
}
356+
}
357+
358+
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
359+
LogError "Entry has no content. Please ensure to provide some content of what changed in this version. See https://aka.ms/azsdk/guideline/changelogs for more info."
360+
$isValid = $false
361+
}
362+
363+
$foundRecommendedSection = $false
364+
$emptySections = @()
365+
foreach ($key in $changeLogEntry.Sections.Keys)
366+
{
367+
$sectionContent = $changeLogEntry.Sections[$key]
368+
if ([System.String]::IsNullOrWhiteSpace(($sectionContent | Out-String)))
369+
{
370+
$emptySections += $key
371+
}
372+
if ($RecommendedSectionHeaders -contains $key)
373+
{
374+
$foundRecommendedSection = $true
375+
}
376+
}
377+
if ($emptySections.Count -gt 0)
378+
{
379+
LogError "The changelog entry has the following sections with no content ($($emptySections -join ', ')). Please ensure to either remove the empty sections or add content to the section."
380+
$isValid = $false
381+
}
382+
if (!$foundRecommendedSection)
383+
{
384+
LogWarning "The changelog entry did not contain any of the recommended sections ($($RecommendedSectionHeaders -join ', ')), please add at least one. See https://aka.ms/azsdk/guideline/changelogs for more info."
385+
}
386+
Write-Host "Changelog validation failed. Please fix errors above and try again."
387+
return $isValid
365388
}

0 commit comments

Comments
 (0)