Skip to content

Commit b0ba977

Browse files
Revert "Verify ChangeLog as ForRelease (#2836)" (Azure#23455)
This reverts commit 6d04c81f6dd95123fd53b5f75bd0849ed9c30da5. Co-authored-by: Chidozie Ononiwu (His Righteousness) <[email protected]>
1 parent cd66a03 commit b0ba977

File tree

1 file changed

+53
-76
lines changed

1 file changed

+53
-76
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

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

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-
}
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+
}
173193

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
180-
}
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+
}
181198

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+
}
222+
}
182223
return $true
183224
}
184225

@@ -321,68 +362,4 @@ function Get-LatestReleaseDateFromChangeLog
321362
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
322363
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
323364
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
388365
}

0 commit comments

Comments
 (0)