Skip to content

Commit f987c7e

Browse files
authored
fix(#155): finalize existing prerelease versions during bump planning (#156)
* fix(#155): finalize existing prerelease versions during bump planning - Update `Update-NovaModuleVersion` to finalize current prerelease versions before incrementing. - Adjust tests to reflect changes in version resolution logic. * fix(#155): update PR description generation requirements - clarify steps for reading prompt and template files - enforce structure for PR description output - ensure creation of output folder if missing
1 parent 7d4b35c commit f987c7e

8 files changed

Lines changed: 63 additions & 47 deletions

.github/prompts/pr-description.prompt.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ Analyze the provided input and:
2828

2929
Be pragmatic: if information is missing, make reasonable assumptions but call them out briefly.
3030

31-
---
31+
Before generating the PR description, you MUST:
3232

33-
## Output format
33+
- Read this prompt file from `.github/prompts/pr-description.prompt.md` directly, even if hidden folders were not
34+
surfaced by an earlier search.
35+
- Read `.github/pull_request_template.md` directly and treat it as authoritative.
36+
- Resolve all relative paths from the repository root.
37+
- Treat `./pr-descriptions/` as a repository-root-relative output folder.
38+
- Never assume `.github/` content is missing just because a previous listing or glob search did not show hidden folders.
3439

35-
You MUST return the PR description using this exact structure:
40+
---
3641

37-
### Pull Request Template
42+
## Output format
3843

39-
.github/pull_request_template.md
44+
You MUST return the PR description using this exact structure, you will find the template in
45+
`.github/pull_request_template.md`:
46+
You MUST fill in all sections, and you MUST NOT modify the template structure.
47+
You MUST create a *.md file in the `./pr-descriptions/` folder with the same name as the PR title, and write the
48+
generated description there.
49+
If the folder does not exist yet, you MUST create it under the repository root before writing the file.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Keep stable `Update-NovaModuleVersion` / `% nova bump` releases on the SemVer ma
3434

3535
### Fixed
3636

37+
- Fix stable `Update-NovaModuleVersion` / `% nova bump` prerelease planning so existing prerelease versions finalize
38+
their current semantic core before any later semantic bump is considered.
39+
- `nova bump --what-if` now plans `2.0.0-preview01 -> 2.0.0` instead of `2.1.0` when commit history resolves to a
40+
`Minor` label.
3741
- Fix `Invoke-NovaBuild` help discovery so it only scans `docs/<ProjectName>/` for PlatyPS
3842
markdown.
3943
- Regular markdown elsewhere under `docs/` no longer breaks the help-generation step.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ These switches keep the behavior explicit and opt-in:
211211
- `Update-NovaModuleVersion -ContinuousIntegration` also falls back to a patch bump when the current `HEAD` already
212212
matches the latest tag, so release automation can seed the next prerelease line without requiring an extra commit
213213
first
214+
- Stable `Update-NovaModuleVersion` / `% nova bump` finalizes any existing prerelease by removing its suffix before
215+
planning a new semantic-core increment, so `2.0.0-preview01` becomes `2.0.0` unless you explicitly pass
216+
`-Preview` / `--preview`
214217
- `Update-NovaModuleVersion` and `% nova bump` treat stable `0.y.z` versions as the SemVer initial-development phase,
215218
so breaking-change bumps stay on the `0.y.z` line by planning the next minor version instead of jumping to `1.0.0`
216219
- `Publish-NovaModule -ContinuousIntegration` restores the built module after publish completes

docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ calculated release label and the exact next version without changing the stored
5959
Use `-ContinuousIntegration` when the same session should first re-activate the built `dist/` module before the version
6060
bump workflow starts. This is useful in CI/self-hosting flows where an earlier command changed the active module state.
6161

62-
When the current version is already a prerelease for the selected release line, Nova finalizes that same semantic
63-
version instead of incrementing again. For example, a `Major` bump from `2.0.0-preview7` resolves to `2.0.0`, not
64-
`3.0.0-preview7`.
62+
When the current version is already a prerelease, Nova finalizes that same semantic version by default instead of
63+
incrementing to the next semantic core. For example, a `Minor` bump from `2.0.0-preview7` resolves to `2.0.0`, not
64+
`2.1.0`. Use `-Preview` when you want to continue the prerelease sequence instead.
6565

6666

6767
## EXAMPLES

src/private/release/GetNovaVersionPartForLabel.ps1

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Get-NovaVersionPartForLabel {
66
[string]$Label = 'Patch'
77
)
88

9-
if (Test-NovaVersionShouldFinalizePrereleaseTarget -CurrentVersion $CurrentVersion -Label $Label) {
9+
if (Test-NovaVersionShouldFinalizePrereleaseTarget -CurrentVersion $CurrentVersion) {
1010
return Get-NovaVersionPartObject -CurrentVersion $CurrentVersion
1111
}
1212

@@ -36,34 +36,12 @@ function Get-NovaVersionPartForLabel {
3636
}
3737

3838
function Test-NovaVersionShouldFinalizePrereleaseTarget {
39-
[CmdletBinding()]
40-
param(
41-
[Parameter(Mandatory)][semver]$CurrentVersion,
42-
[Parameter(Mandatory)][string]$Label
43-
)
44-
45-
if ( [string]::IsNullOrWhiteSpace($CurrentVersion.PreReleaseLabel)) {
46-
return $false
47-
}
48-
49-
return (Get-NovaVersionTargetLabelForPrerelease -CurrentVersion $CurrentVersion) -eq $Label
50-
}
51-
52-
function Get-NovaVersionTargetLabelForPrerelease {
5339
[CmdletBinding()]
5440
param(
5541
[Parameter(Mandatory)][semver]$CurrentVersion
5642
)
5743

58-
if ($CurrentVersion.Patch -gt 0) {
59-
return 'Patch'
60-
}
61-
62-
if ($CurrentVersion.Minor -gt 0) {
63-
return 'Minor'
64-
}
65-
66-
return 'Major'
44+
return -not [string]::IsNullOrWhiteSpace($CurrentVersion.PreReleaseLabel)
6745
}
6846

6947
function Get-NovaVersionPartObject {

tests/CoverageGaps.ReleaseInternals.Tests.ps1

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ Describe 'Coverage gaps for release and git internals' {
5555
}
5656
}
5757

58-
It 'Get-NovaVersionPartForLabel finalizes prerelease targets or advances to the next stable core when <Name>' -ForEach @(
59-
@{Name = 'major prerelease already targets the current release line'; CurrentVersion = '2.0.0-preview7'; Label = 'Major'; Expected = '2.0.0'}
60-
@{Name = 'minor prerelease already targets the current release line'; CurrentVersion = '1.3.0-preview7'; Label = 'Minor'; Expected = '1.3.0'}
61-
@{Name = 'patch prerelease already targets the current release line'; CurrentVersion = '1.2.4-preview7'; Label = 'Patch'; Expected = '1.2.4'}
62-
@{Name = 'major prerelease on a lower release line advances to the next major'; CurrentVersion = '1.2.3-preview7'; Label = 'Major'; Expected = '2.0.0'}
63-
@{Name = 'minor prerelease on a lower release line advances to the next minor'; CurrentVersion = '1.2.3-preview7'; Label = 'Minor'; Expected = '1.3.0'}
64-
@{Name = 'patch prerelease on the current patch line finalizes that line'; CurrentVersion = '1.2.3-preview7'; Label = 'Patch'; Expected = '1.2.3'}
58+
It 'Get-NovaVersionPartForLabel finalizes any existing prerelease on the current semantic core when <Name>' -ForEach @(
59+
@{Name = 'a breaking-change label targets a major prerelease'; CurrentVersion = '2.0.0-preview7'; Label = 'Major'; Expected = '2.0.0'}
60+
@{Name = 'a feature label still finalizes a major prerelease'; CurrentVersion = '2.0.0-preview7'; Label = 'Minor'; Expected = '2.0.0'}
61+
@{Name = 'a patch label still finalizes a minor prerelease'; CurrentVersion = '1.3.0-preview7'; Label = 'Patch'; Expected = '1.3.0'}
62+
@{Name = 'a breaking-change label still finalizes a patch prerelease'; CurrentVersion = '1.2.4-preview7'; Label = 'Major'; Expected = '1.2.4'}
6563
) {
6664
InModuleScope $script:moduleName -Parameters @{TestCase = $_} {
6765
param($TestCase)
@@ -109,11 +107,11 @@ Describe 'Coverage gaps for release and git internals' {
109107
}
110108
}
111109

112-
It 'Get-NovaVersionUpdatePlan resolves prerelease versions to the expected next stable target when <Name>' -ForEach @(
113-
@{Name = 'finalizing a major prerelease line'; CurrentVersion = '2.0.0-preview7'; Label = 'Major'; ExpectedVersion = '2.0.0'}
114-
@{Name = 'finalizing a minor prerelease line'; CurrentVersion = '1.3.0-preview7'; Label = 'Minor'; ExpectedVersion = '1.3.0'}
115-
@{Name = 'finalizing a patch prerelease line'; CurrentVersion = '1.2.4-preview7'; Label = 'Patch'; ExpectedVersion = '1.2.4'}
116-
@{Name = 'advancing from an earlier prerelease line to the next minor'; CurrentVersion = '1.2.3-preview7'; Label = 'Minor'; ExpectedVersion = '1.3.0'}
110+
It 'Get-NovaVersionUpdatePlan resolves prerelease versions to the current stable target when <Name>' -ForEach @(
111+
@{Name = 'finalizing a major prerelease after a breaking change'; CurrentVersion = '2.0.0-preview7'; Label = 'Major'; ExpectedVersion = '2.0.0'}
112+
@{Name = 'finalizing a major prerelease after a feature change'; CurrentVersion = '2.0.0-preview7'; Label = 'Minor'; ExpectedVersion = '2.0.0'}
113+
@{Name = 'finalizing a minor prerelease after a patch change'; CurrentVersion = '1.3.0-preview7'; Label = 'Patch'; ExpectedVersion = '1.3.0'}
114+
@{Name = 'finalizing a patch prerelease after a breaking change'; CurrentVersion = '1.2.4-preview7'; Label = 'Major'; ExpectedVersion = '1.2.4'}
117115
) {
118116
InModuleScope $script:moduleName -Parameters @{TestCase = $_} {
119117
param($TestCase)

tests/NovaCommandModel.BumpAndCli.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ Describe 'Nova command model - bump and CLI confirmation behavior' {
491491
}
492492
}
493493

494-
It 'Update-NovaModuleVersion preserves nested package repository objects when writing the bumped version' {
494+
It 'Update-NovaModuleVersion finalizes an existing prerelease while preserving nested package repository objects' {
495495
InModuleScope $script:moduleName {
496496
$projectRoot = Join-Path $TestDrive 'package-repository-bump-project'
497497
New-Item -ItemType Directory -Path $projectRoot -Force | Out-Null
@@ -531,9 +531,9 @@ Describe 'Nova command model - bump and CLI confirmation behavior' {
531531
$updatedProject = Get-Content -LiteralPath $projectJsonPath -Raw | ConvertFrom-Json
532532

533533
$result.PreviousVersion | Should -Be '1.5.2-preview'
534-
$result.NewVersion | Should -Be '2.0.0'
534+
$result.NewVersion | Should -Be '1.5.2'
535535
$result.Label | Should -Be 'Major'
536-
$updatedProject.Version | Should -Be '2.0.0'
536+
$updatedProject.Version | Should -Be '1.5.2'
537537
($updatedProject.Package.Repositories[0] -is [string]) | Should -BeFalse
538538
$updatedProject.Package.Repositories[0].Name | Should -Be 'staging'
539539
$updatedProject.Package.Repositories[0].Auth.TokenEnvironmentVariable | Should -Be 'NEXUS_STAGING_TOKEN'

tests/NovaCommandModel.StandaloneCli.Tests.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,29 @@ Describe '$projectName tests' {
338338
}
339339
}
340340

341+
It 'Install-NovaCli finalizes prerelease versions during stable what-if bumps' {
342+
Assert-TestInstalledNovaCliBumpBehavior -DistModuleDir $script:distModuleDir -TestDriveRoot $TestDrive -TestCase @{
343+
TargetDirectory = 'prerelease-finalize-bin'
344+
ProjectName = 'CliPrereleaseFinalizeProject'
345+
ProjectGuid = '45444444-4444-4444-4444-444444444444'
346+
FunctionName = 'Invoke-TestCliPrereleaseFinalize'
347+
CurrentVersion = '2.0.0-preview01'
348+
CommitMessage = 'feat: finalize prerelease stable bump planning'
349+
Arguments = @('bump', '--what-if')
350+
ExpectedPatterns = @(
351+
'What if:'
352+
'Version plan: 2\.0\.0-preview01 -> 2\.0\.0 \| Label: Minor \| Commits: 1'
353+
)
354+
UnexpectedPatterns = @(
355+
'Version plan: 2\.0\.0-preview01 -> 2\.1\.0'
356+
'Unknown argument:'
357+
'Version bumped to :'
358+
)
359+
ExpectedWarningCount = 0
360+
ExpectedVersionAfterBump = '2.0.0-preview01'
361+
}
362+
}
363+
341364
It 'Install-NovaCli rejects unsupported nova init invocations with clear migration guidance' -ForEach @(
342365
@{
343366
Name = 'WhatIf'

0 commit comments

Comments
 (0)