Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be431bc

Browse files
Add prompt before replasing latest release title on prepare release run (Azure#18522)
Co-authored-by: Chidozie Ononiwu <[email protected]>
1 parent 74b93c7 commit be431bc

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,15 @@ function Remove-EmptySections {
351351
}
352352
$ChangeLogEntry.ReleaseContent = $sanitizedReleaseContent.ToArray()
353353
}
354+
}
355+
356+
function Get-LatestReleaseDateFromChangeLog
357+
{
358+
param (
359+
[Parameter(Mandatory = $true)]
360+
$ChangeLogLocation
361+
)
362+
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
363+
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
364+
return ($latestVersion -as [DateTime])
354365
}

eng/common/scripts/Prepare-Release.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,17 @@ if ($releaseTrackingOnly)
177177

178178
if (Test-Path "Function:SetPackageVersion")
179179
{
180-
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion -ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
181-
-PackageProperties $packageProperties
180+
$replaceLatestEntryTitle = $true
181+
$latestVersion = Get-LatestReleaseDateFromChangeLog -ChangeLogLocation $packageProperties.ChangeLogPath
182+
if ($latestVersion)
183+
{
184+
$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)."
185+
while (($readInput = Read-Host -Prompt $promptMessage) -notmatch '^[yn]$'){ }
186+
$replaceLatestEntryTitle = ($readInput -eq "y")
187+
}
188+
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion `
189+
-ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
190+
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle
182191
}
183192
else
184193
{

0 commit comments

Comments
 (0)