From 59b66f552ca7398acea9b0704375e7abfd8e6805 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Mon, 1 Nov 2021 17:26:46 -0700 Subject: [PATCH] Add prompt before replasing latest release title on prepare release run --- eng/common/scripts/ChangeLog-Operations.ps1 | 11 +++++++++++ eng/common/scripts/Prepare-Release.ps1 | 13 +++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/ChangeLog-Operations.ps1 b/eng/common/scripts/ChangeLog-Operations.ps1 index 02f4981302466..df2bc9d1d29c2 100644 --- a/eng/common/scripts/ChangeLog-Operations.ps1 +++ b/eng/common/scripts/ChangeLog-Operations.ps1 @@ -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]) } \ No newline at end of file diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index 5a8940266bf52..e764108a24edd 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -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 {