Skip to content

Commit

Permalink
Add prompt before replasing latest release title on prepare release r…
Browse files Browse the repository at this point in the history
…un (Azure#25185)

Co-authored-by: Chidozie Ononiwu <[email protected]>
  • Loading branch information
azure-sdk and chidozieononiwu authored Nov 4, 2021
1 parent 1be835d commit 6ffbc9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 11 additions & 0 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
13 changes: 11 additions & 2 deletions eng/common/scripts/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 6ffbc9e

Please sign in to comment.