Skip to content

Commit a50cc58

Browse files
authored
#175 fix: require explicit override for no-git bump fallback (#177)
Stop `nova bump` and `Update-NovaModuleVersion` from silently presenting `Patch | Commits: 0` when Git-based bump inference is unavailable. Add `-OverrideWarning` / `--override-warning` / `-o` as the explicit opt-in for intentional non-git Patch fallback flows, add regression coverage, and update bump docs and changelog. Closes #175
1 parent 47d82e1 commit a50cc58

15 files changed

Lines changed: 233 additions & 16 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Fixed
2020

2121
- Fixed `nova bump` and `Update-NovaModuleVersion` so nested project folders now reuse parent Git repository history for bump inference instead of silently falling back to `Patch`.
22+
- Fixed `nova bump` and `Update-NovaModuleVersion` so non-git bump flows now stop with a clear override-warning requirement instead of silently presenting `Patch | Commits: 0` as if it were an inferred result.
2223

2324
### Security
2425

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ These switches keep the behavior explicit and opt-in:
223223
- `Update-NovaModuleVersion -ContinuousIntegration` also falls back to a patch bump when the current `HEAD` already
224224
matches the latest tag, so release automation can seed the next prerelease line without requiring an extra commit
225225
first
226+
- `Update-NovaModuleVersion` and `% nova bump` now stop when Git-based bump inference is unavailable, unless you
227+
explicitly opt in to the Patch fallback with `-OverrideWarning` / `--override-warning` / `-o` for a non-git
228+
example/template flow
226229
- `Update-NovaModuleVersion` and `% nova bump` treat stable `0.y.z` versions as the SemVer initial-development phase,
227230
so breaking-change bumps stay on the `0.y.z` line by planning the next minor version instead of jumping to `1.0.0`
228231
- `Publish-NovaModule -ContinuousIntegration` restores the built module after publish completes

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Updates the project version in `project.json` based on git commit history.
2020
### __AllParameterSets
2121

2222
```text
23-
PS> Update-NovaModuleVersion [[-Path] <string>] [-Preview] [-ContinuousIntegration] [-WhatIf] [-Confirm] [<CommonParameters>]
23+
PS> Update-NovaModuleVersion [[-Path] <string>] [-Preview] [-ContinuousIntegration] [-OverrideWarning] [-WhatIf] [-Confirm] [<CommonParameters>]
2424
```
2525

2626
## DESCRIPTION
@@ -49,8 +49,10 @@ reports the detected `Major` label so you can see that the commit set contained
4949
guidance about manually setting `1.0.0` once the software is stable. With `-Preview`, stable versions still enter the
5050
next patch preview track instead of applying semantic history inference to the semantic core.
5151

52-
When Git tags exist, only commits since the latest tag are considered. If the folder is not a Git repository, the
53-
command falls back to a patch bump.
52+
When Git tags exist, only commits since the latest tag are considered. If Git-based inference is unavailable because the
53+
project path is not inside a Git repository, the command stops with a clear warning/error instead of silently presenting
54+
an inferred-looking patch result. Use `-OverrideWarning` only when you intentionally want that Patch fallback, for
55+
example in example/template flows outside Git.
5456

5557
If the repository exists but has no commits yet, the command stops with: `Cannot bump version because the repository
5658
has no commits yet. Create an initial commit first.`
@@ -186,6 +188,19 @@ CommitCount: 34
186188
Shows how stable `0.y.z` bumps still warn that `1.0.0` must be set manually when the API becomes stable, while
187189
breaking-change commits on that line continue to plan the next minor version instead of jumping straight to `1.0.0`.
188190

191+
### EXAMPLE 10
192+
193+
```text
194+
PS> Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf
195+
196+
WARNING: Cannot infer the version bump label from Git history because no Git repository was found for this project path. Use -OverrideWarning to continue intentionally with a Patch fallback.
197+
198+
What if: Performing the operation "Update module version using Patch release label" on target "project.json".
199+
```
200+
201+
Shows how to opt in explicitly to the Patch fallback when a project lives outside a Git repository and Nova therefore
202+
cannot infer the semantic label from commit history.
203+
189204
## PARAMETERS
190205

191206
### -Path
@@ -259,6 +274,30 @@ AcceptedValues: [ ]
259274
HelpMessage: ''
260275
```
261276

277+
### -OverrideWarning
278+
279+
Allow the version bump to continue with the explicit Patch fallback when Git-based inference is unavailable.
280+
281+
Use this only when you intentionally want to bump a project outside a Git repository, for example in example/template
282+
flows where no commit history exists.
283+
284+
```yaml
285+
Type: System.Management.Automation.SwitchParameter
286+
DefaultValue: False
287+
SupportsWildcards: false
288+
Aliases: [ ]
289+
ParameterSets:
290+
- Name: (All)
291+
Position: Named
292+
IsRequired: false
293+
ValueFromPipeline: false
294+
ValueFromPipelineByPropertyName: false
295+
ValueFromRemainingArguments: false
296+
DontShow: false
297+
AcceptedValues: [ ]
298+
HelpMessage: ''
299+
```
300+
262301
### CommonParameters
263302

264303
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
@@ -291,6 +330,9 @@ reflect the new version.
291330
When `-ContinuousIntegration` is used with a real update, the command re-activates the built `dist/` module first. When
292331
combined with `-WhatIf`, Nova still previews the bump without changing the loaded module state.
293332

333+
When Git-based inference is unavailable, `Update-NovaModuleVersion` now requires `-OverrideWarning` before it continues
334+
with the intentional Patch fallback.
335+
294336
## RELATED LINKS
295337

296338
- https://github.com/stiwicourage/NovaModuleTools/blob/main/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md

docs/commands.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,13 @@ <h3><code>Update-NovaModuleVersion</code> / <code>% nova bump</code></h3>
476476
<ul class="plain-list">
477477
<li><strong>Best for:</strong> Git-driven semantic version updates</li>
478478
<li><strong>Key parameters:</strong> <code>-Path</code>, <code>-Preview</code>,
479-
<code>-ContinuousIntegration</code>, or the CLI form <code>--preview</code> /
480-
<code>-p</code> and <code>--continuous-integration</code> / <code>-i</code></li>
481-
<li><strong>Notable behavior:</strong> falls back to a patch bump when the folder is not a
482-
Git repository, but throws when the repository exists and has no commits yet
479+
<code>-ContinuousIntegration</code>, <code>-OverrideWarning</code>, or the CLI form
480+
<code>--preview</code> / <code>-p</code>, <code>--continuous-integration</code> /
481+
<code>-i</code>, and <code>--override-warning</code> / <code>-o</code></li>
482+
<li><strong>Notable behavior:</strong> stops when Git-based inference is unavailable, unless
483+
you explicitly opt in to the Patch fallback with <code>-OverrideWarning</code> /
484+
<code>--override-warning</code> / <code>-o</code>; it still throws when the repository
485+
exists and has no commits yet
483486
</li>
484487
<li><strong>Major-zero rule:</strong> stable <code>0.y.z</code> projects keep
485488
breaking-change
@@ -504,10 +507,12 @@ <h3><code>Update-NovaModuleVersion</code> / <code>% nova bump</code></h3>
504507
</div>
505508
<div class="surface-example__surface" data-command-surface="powershell">
506509
<pre><code>PS&gt; Update-NovaModuleVersion -Preview -WhatIf
510+
PS&gt; Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf
507511
PS&gt; Update-NovaModuleVersion -ContinuousIntegration</code></pre>
508512
</div>
509513
<div class="surface-example__surface" data-command-surface="command-line" hidden>
510514
<pre><code>% nova bump --preview --what-if
515+
% nova bump --override-warning --what-if
511516
% nova bump --continuous-integration
512517
% nova bump --preview --confirm</code></pre>
513518
</div>

docs/versioning-and-updates.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,12 @@ <h3>How Nova chooses the bump label</h3>
177177
<pre><code>0.0.1 + Patch -> 0.0.2
178178
0.1.0 + Minor -> 0.2.0
179179
0.1.0 + Major -> 0.2.0</code></pre>
180-
<p>When Git tags exist, Nova uses commits since the latest tag. When the folder is not a Git repository,
181-
Nova falls back to a patch bump. When the repository exists but has no commits yet, Nova stops with
182-
a clear error.</p>
180+
<p>When Git tags exist, Nova uses commits since the latest tag. When Git-based inference is unavailable
181+
because the project path is not inside a Git repository, Nova stops instead of silently presenting a
182+
normal-looking patch result. Use <code>-OverrideWarning</code> or the CLI form <code>% nova bump
183+
--override-warning</code> / <code>% nova bump -o</code> only when you intentionally want that
184+
Patch fallback for an example/template flow outside Git. When the repository exists but has no
185+
commits yet, Nova still stops with a clear error.</p>
183186
<p>Nova treats prerelease versions as previews of a specific semantic version target. That means a bump
184187
does not blindly carry prerelease labels such as <code>preview7</code> into the next major, minor,
185188
or
@@ -215,11 +218,13 @@ <h3>How Nova chooses the bump label</h3>
215218
<div class="surface-example__surface" data-command-surface="powershell">
216219
<pre><code>PS&gt; Update-NovaModuleVersion -WhatIf
217220
PS&gt; Update-NovaModuleVersion -Preview -WhatIf
221+
PS&gt; Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf
218222
PS&gt; Update-NovaModuleVersion -ContinuousIntegration</code></pre>
219223
</div>
220224
<div class="surface-example__surface" data-command-surface="command-line" hidden>
221225
<pre><code>% nova bump --what-if
222226
% nova bump --preview --what-if
227+
% nova bump --override-warning --what-if
223228
% nova bump --continuous-integration
224229
% nova bump --confirm</code></pre>
225230
</div>

src/private/cli/ConvertFromNovaBumpCliArgument.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ function ConvertFrom-NovaBumpCliArgument {
99
'-p' = 'Preview'
1010
'--continuous-integration' = 'ContinuousIntegration'
1111
'-i' = 'ContinuousIntegration'
12+
'--override-warning' = 'OverrideWarning'
13+
'-o' = 'OverrideWarning'
1214
}
1315
}

src/private/cli/GetNovaCliArgumentRoutingState.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function Get-NovaCliLegacyOptionReplacement {
6868
'-installed' = "'--installed' or '-i'"
6969
'-local' = "'--local' or '-l'"
7070
'-moduledirectorypath' = "'--path' or '-p'"
71+
'-overridewarning' = "'--override-warning' or '-o'"
7172
'-packagepath' = "'--path' or '-p'"
7273
'-packagetype' = "'--type' or '-t'"
7374
'-path' = "'--path' or '-p'"

src/private/release/GetNovaVersionUpdateWorkflowContext.ps1

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,54 @@ function Get-NovaVersionUpdateWorkflowContext {
33
param(
44
[Parameter(Mandatory)][string]$ProjectRoot,
55
[switch]$PreviewRelease,
6-
[switch]$ContinuousIntegrationRequested
6+
[switch]$ContinuousIntegrationRequested,
7+
[switch]$OverrideWarningRequested
78
)
89

910
$projectInfo = Get-NovaProjectInfo -Path $ProjectRoot
1011
$commitMessages = @(Get-GitCommitMessageForVersionBump -ProjectRoot $ProjectRoot)
12+
Assert-NovaVersionBumpInferenceAvailability -ProjectRoot $ProjectRoot -CommitMessages $commitMessages -OverrideWarningRequested:$OverrideWarningRequested
1113
$label = Get-NovaVersionLabelForBump -ProjectRoot $ProjectRoot -CommitMessages $commitMessages -ContinuousIntegrationRequested:$ContinuousIntegrationRequested
1214
$labelResolution = Get-NovaVersionUpdateLabelResolution -ProjectInfo $projectInfo -Label $label -PreviewRelease:$PreviewRelease
1315
$versionUpdatePlan = Get-NovaVersionUpdatePlan -ProjectInfo $projectInfo -Label $labelResolution.EffectiveLabel -PreviewRelease:$PreviewRelease
1416

1517
return Get-NovaVersionUpdateWorkflowContextObject -ProjectRoot $ProjectRoot -ProjectInfo $projectInfo -CommitMessages $commitMessages -Label $label -EffectiveLabel $labelResolution.EffectiveLabel -AdvisoryMessage $labelResolution.AdvisoryMessage -VersionUpdatePlan $versionUpdatePlan -PreviewRelease:$PreviewRelease -ContinuousIntegrationRequested:$ContinuousIntegrationRequested
1618
}
1719

20+
function Assert-NovaVersionBumpInferenceAvailability {
21+
[CmdletBinding()]
22+
param(
23+
[Parameter(Mandatory)][string]$ProjectRoot,
24+
[AllowEmptyCollection()][string[]]$CommitMessages = @(),
25+
[switch]$OverrideWarningRequested
26+
)
27+
28+
if ($CommitMessages.Count -gt 0) {
29+
return
30+
}
31+
32+
if (Test-GitRepositoryIsAvailable -ProjectRoot $ProjectRoot) {
33+
return
34+
}
35+
36+
$message = Get-NovaVersionBumpInferenceUnavailableMessage
37+
Write-Warning $message
38+
39+
if ($OverrideWarningRequested) {
40+
Write-Verbose 'Continuing version bump because OverrideWarning was specified and Git-based bump inference is unavailable.'
41+
return
42+
}
43+
44+
Stop-NovaOperation -Message $message -ErrorId 'Nova.Workflow.VersionBumpInferenceUnavailable' -Category InvalidOperation -TargetObject $ProjectRoot
45+
}
46+
47+
function Get-NovaVersionBumpInferenceUnavailableMessage {
48+
[CmdletBinding()]
49+
param()
50+
51+
return 'Cannot infer the version bump label from Git history because no Git repository was found for this project path. Use -OverrideWarning / --override-warning / -o to continue intentionally with a Patch fallback, for example in example or template flows.'
52+
}
53+
1854
function Get-NovaVersionUpdateLabelResolution {
1955
[CmdletBinding()]
2056
param(

src/public/UpdateNovaModuleVersion.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ function Update-NovaModuleVersion {
33
param(
44
[string]$Path = (Get-Location).Path,
55
[switch]$Preview,
6-
[switch]$ContinuousIntegration
6+
[switch]$ContinuousIntegration,
7+
[switch]$OverrideWarning
78
)
89

910
$projectRoot = (Resolve-Path -LiteralPath $Path).Path
@@ -12,7 +13,7 @@ function Update-NovaModuleVersion {
1213
return $ciActivation.Result
1314
}
1415

15-
$workflowContext = Get-NovaVersionUpdateWorkflowContext -ProjectRoot $projectRoot -PreviewRelease:$Preview -ContinuousIntegrationRequested:$ContinuousIntegration
16+
$workflowContext = Get-NovaVersionUpdateWorkflowContext -ProjectRoot $projectRoot -PreviewRelease:$Preview -ContinuousIntegrationRequested:$ContinuousIntegration -OverrideWarningRequested:$OverrideWarning
1617
$shouldRun = $PSCmdlet.ShouldProcess($workflowContext.Target, $workflowContext.Action)
1718
$result = Invoke-NovaVersionUpdateWorkflow -WorkflowContext $workflowContext -ShouldRun:$shouldRun -WhatIfEnabled:$WhatIfPreference
1819
if ($null -eq $result) {
@@ -23,4 +24,3 @@ function Update-NovaModuleVersion {
2324

2425
return $result
2526
}
26-

src/resources/cli/help/bump.psd1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'When the current stable version is 0.y.z, Nova keeps breaking-change bumps on the initial-development line and plans the next minor version instead of jumping to 1.0.0.',
88
'Set 1.0.0 manually once the software is stable. After that, nova bump can increment major versions normally.',
99
'Use --preview when you want an explicit prerelease iteration instead of the next stable semantic version.',
10+
'When Git-based bump inference is unavailable, nova bump stops unless you opt in to the Patch fallback with --override-warning.',
1011
'For more information, documentation, and examples, visit:',
1112
'https://www.novamoduletools.com/versioning-and-updates.html#bump'
1213
)
@@ -40,6 +41,12 @@
4041
Long = '--continuous-integration'
4142
Placeholder = ''
4243
Description = 'Re-import the built dist module before the version bump workflow starts so later CI steps keep using the correct built module state.'
44+
},
45+
@{
46+
Short = '-o'
47+
Long = '--override-warning'
48+
Placeholder = ''
49+
Description = 'Allow an intentional Patch fallback when Git-based bump inference is unavailable, for example in example or template flows outside a Git repository.'
4350
}
4451
)
4552
Examples = @(
@@ -58,6 +65,10 @@
5865
@{
5966
Command = 'nova bump --continuous-integration --what-if'
6067
Description = 'Preview the next version by using the CI-safe routed bump entrypoint without changing project.json.'
68+
},
69+
@{
70+
Command = 'nova bump --override-warning --what-if'
71+
Description = 'Preview the explicit Patch fallback when Git-based bump inference is unavailable outside a Git repository.'
6172
}
6273
)
6374
}

0 commit comments

Comments
 (0)