Add prompt before replasing latest release title on prepare release run (#3036)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-11-03 19:22:15 -07:00 committed by GitHub
parent 2ce1b65601
commit 9043580dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -351,4 +351,15 @@ function Remove-EmptySections {
}
$ChangeLogEntry.ReleaseContent = $sanitizedReleaseContent.ToArray()
}
}
function Get-LatestReleaseDateFromChangeLog
{
param (
[Parameter(Mandatory = $true)]
$ChangeLogLocation
)
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
return ($latestVersion -as [DateTime])
}

View File

@ -177,8 +177,17 @@ if ($releaseTrackingOnly)
if (Test-Path "Function:SetPackageVersion")
{
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion -ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
-PackageProperties $packageProperties
$replaceLatestEntryTitle = $true
$latestVersion = Get-LatestReleaseDateFromChangeLog -ChangeLogLocation $packageProperties.ChangeLogPath
if ($latestVersion)
{
$promptMessage = "The latest entry in the CHANGELOG.md already has a release date. Do you want to replace the latest entry title? Please enter (y or n)."
while (($readInput = Read-Host -Prompt $promptMessage) -notmatch '^[yn]$'){ }
$replaceLatestEntryTitle = ($readInput -eq "y")
}
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion `
-ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle
}
else
{