From 8f901a0bc10b62ec49fd2803f76d1cc69b3ba690 Mon Sep 17 00:00:00 2001 From: Stiwi Gabriel Courage Date: Fri, 8 May 2026 13:16:23 +0200 Subject: [PATCH] #175 fix: require explicit override for no-git bump fallback 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 --- CHANGELOG.md | 1 + README.md | 3 + .../en-US/Update-NovaModuleVersion.md | 48 +++++++++++++- docs/commands.html | 13 ++-- docs/versioning-and-updates.html | 11 +++- .../cli/ConvertFromNovaBumpCliArgument.ps1 | 2 + .../cli/GetNovaCliArgumentRoutingState.ps1 | 1 + .../GetNovaVersionUpdateWorkflowContext.ps1 | 38 +++++++++++- src/public/UpdateNovaModuleVersion.ps1 | 6 +- src/resources/cli/help/bump.psd1 | 11 ++++ tests/CoverageGaps.Cli.TestSupport.ps1 | 2 + tests/CoverageGaps.ReleaseInternals.Tests.ps1 | 36 +++++++++++ tests/NovaCommandModel.BumpAndCli.Tests.ps1 | 62 ++++++++++++++++++- ...el.StandaloneCli.OverrideWarning.Tests.ps1 | 1 + .../NovaCommandModel.StandaloneCli.Tests.ps1 | 14 +++++ 15 files changed, 233 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58489022..4be104fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - 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`. +- 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. ### Security diff --git a/README.md b/README.md index 102e4648..714472d0 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,9 @@ These switches keep the behavior explicit and opt-in: - `Update-NovaModuleVersion -ContinuousIntegration` also falls back to a patch bump when the current `HEAD` already matches the latest tag, so release automation can seed the next prerelease line without requiring an extra commit first +- `Update-NovaModuleVersion` and `% nova bump` now stop when Git-based bump inference is unavailable, unless you + explicitly opt in to the Patch fallback with `-OverrideWarning` / `--override-warning` / `-o` for a non-git + example/template flow - `Update-NovaModuleVersion` and `% nova bump` treat stable `0.y.z` versions as the SemVer initial-development phase, so breaking-change bumps stay on the `0.y.z` line by planning the next minor version instead of jumping to `1.0.0` - `Publish-NovaModule -ContinuousIntegration` restores the built module after publish completes diff --git a/docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md b/docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md index 695839b9..c84053ce 100644 --- a/docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md +++ b/docs/NovaModuleTools/en-US/Update-NovaModuleVersion.md @@ -20,7 +20,7 @@ Updates the project version in `project.json` based on git commit history. ### __AllParameterSets ```text -PS> Update-NovaModuleVersion [[-Path] ] [-Preview] [-ContinuousIntegration] [-WhatIf] [-Confirm] [] +PS> Update-NovaModuleVersion [[-Path] ] [-Preview] [-ContinuousIntegration] [-OverrideWarning] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -49,8 +49,10 @@ reports the detected `Major` label so you can see that the commit set contained guidance about manually setting `1.0.0` once the software is stable. With `-Preview`, stable versions still enter the next patch preview track instead of applying semantic history inference to the semantic core. -When Git tags exist, only commits since the latest tag are considered. If the folder is not a Git repository, the -command falls back to a patch bump. +When Git tags exist, only commits since the latest tag are considered. If Git-based inference is unavailable because the +project path is not inside a Git repository, the command stops with a clear warning/error instead of silently presenting +an inferred-looking patch result. Use `-OverrideWarning` only when you intentionally want that Patch fallback, for +example in example/template flows outside Git. If the repository exists but has no commits yet, the command stops with: `Cannot bump version because the repository has no commits yet. Create an initial commit first.` @@ -186,6 +188,19 @@ CommitCount: 34 Shows how stable `0.y.z` bumps still warn that `1.0.0` must be set manually when the API becomes stable, while breaking-change commits on that line continue to plan the next minor version instead of jumping straight to `1.0.0`. +### EXAMPLE 10 + +```text +PS> Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf + +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. + +What if: Performing the operation "Update module version using Patch release label" on target "project.json". +``` + +Shows how to opt in explicitly to the Patch fallback when a project lives outside a Git repository and Nova therefore +cannot infer the semantic label from commit history. + ## PARAMETERS ### -Path @@ -259,6 +274,30 @@ AcceptedValues: [ ] HelpMessage: '' ``` +### -OverrideWarning + +Allow the version bump to continue with the explicit Patch fallback when Git-based inference is unavailable. + +Use this only when you intentionally want to bump a project outside a Git repository, for example in example/template +flows where no commit history exists. + +```yaml +Type: System.Management.Automation.SwitchParameter +DefaultValue: False +SupportsWildcards: false +Aliases: [ ] +ParameterSets: + - Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [ ] +HelpMessage: '' +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, @@ -291,6 +330,9 @@ reflect the new version. When `-ContinuousIntegration` is used with a real update, the command re-activates the built `dist/` module first. When combined with `-WhatIf`, Nova still previews the bump without changing the loaded module state. +When Git-based inference is unavailable, `Update-NovaModuleVersion` now requires `-OverrideWarning` before it continues +with the intentional Patch fallback. + ## RELATED LINKS - https://github.com/stiwicourage/NovaModuleTools/blob/main/docs/NovaModuleTools/en-US/Get-NovaProjectInfo.md diff --git a/docs/commands.html b/docs/commands.html index 8a75e72a..6b6401cf 100644 --- a/docs/commands.html +++ b/docs/commands.html @@ -476,10 +476,13 @@

Update-NovaModuleVersion / % nova bump

  • Best for: Git-driven semantic version updates
  • Key parameters: -Path, -Preview, - -ContinuousIntegration, or the CLI form --preview / - -p and --continuous-integration / -i
  • -
  • Notable behavior: falls back to a patch bump when the folder is not a - Git repository, but throws when the repository exists and has no commits yet + -ContinuousIntegration, -OverrideWarning, or the CLI form + --preview / -p, --continuous-integration / + -i, and --override-warning / -o
  • +
  • Notable behavior: stops when Git-based inference is unavailable, unless + you explicitly opt in to the Patch fallback with -OverrideWarning / + --override-warning / -o; it still throws when the repository + exists and has no commits yet
  • Major-zero rule: stable 0.y.z projects keep breaking-change @@ -504,10 +507,12 @@

    Update-NovaModuleVersion / % nova bump

    PS> Update-NovaModuleVersion -Preview -WhatIf
    +PS> Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf
     PS> Update-NovaModuleVersion -ContinuousIntegration
    diff --git a/docs/versioning-and-updates.html b/docs/versioning-and-updates.html index 211f6348..ee9b80fd 100644 --- a/docs/versioning-and-updates.html +++ b/docs/versioning-and-updates.html @@ -177,9 +177,12 @@

    How Nova chooses the bump label

    0.0.1 + Patch -> 0.0.2
     0.1.0 + Minor -> 0.2.0
     0.1.0 + Major -> 0.2.0
    -

    When Git tags exist, Nova uses commits since the latest tag. When the folder is not a Git repository, - Nova falls back to a patch bump. When the repository exists but has no commits yet, Nova stops with - a clear error.

    +

    When Git tags exist, Nova uses commits since the latest tag. When Git-based inference is unavailable + because the project path is not inside a Git repository, Nova stops instead of silently presenting a + normal-looking patch result. Use -OverrideWarning or the CLI form % nova bump + --override-warning / % nova bump -o only when you intentionally want that + Patch fallback for an example/template flow outside Git. When the repository exists but has no + commits yet, Nova still stops with a clear error.

    Nova treats prerelease versions as previews of a specific semantic version target. That means a bump does not blindly carry prerelease labels such as preview7 into the next major, minor, or @@ -215,11 +218,13 @@

    How Nova chooses the bump label

    PS> Update-NovaModuleVersion -WhatIf
     PS> Update-NovaModuleVersion -Preview -WhatIf
    +PS> Update-NovaModuleVersion -Path ./src/resources/example -OverrideWarning -WhatIf
     PS> Update-NovaModuleVersion -ContinuousIntegration
    diff --git a/src/private/cli/ConvertFromNovaBumpCliArgument.ps1 b/src/private/cli/ConvertFromNovaBumpCliArgument.ps1 index 3aaa7a31..d51a1246 100644 --- a/src/private/cli/ConvertFromNovaBumpCliArgument.ps1 +++ b/src/private/cli/ConvertFromNovaBumpCliArgument.ps1 @@ -9,5 +9,7 @@ function ConvertFrom-NovaBumpCliArgument { '-p' = 'Preview' '--continuous-integration' = 'ContinuousIntegration' '-i' = 'ContinuousIntegration' + '--override-warning' = 'OverrideWarning' + '-o' = 'OverrideWarning' } } diff --git a/src/private/cli/GetNovaCliArgumentRoutingState.ps1 b/src/private/cli/GetNovaCliArgumentRoutingState.ps1 index 73365bd4..b835c318 100644 --- a/src/private/cli/GetNovaCliArgumentRoutingState.ps1 +++ b/src/private/cli/GetNovaCliArgumentRoutingState.ps1 @@ -68,6 +68,7 @@ function Get-NovaCliLegacyOptionReplacement { '-installed' = "'--installed' or '-i'" '-local' = "'--local' or '-l'" '-moduledirectorypath' = "'--path' or '-p'" + '-overridewarning' = "'--override-warning' or '-o'" '-packagepath' = "'--path' or '-p'" '-packagetype' = "'--type' or '-t'" '-path' = "'--path' or '-p'" diff --git a/src/private/release/GetNovaVersionUpdateWorkflowContext.ps1 b/src/private/release/GetNovaVersionUpdateWorkflowContext.ps1 index f6b3223d..1e32935d 100644 --- a/src/private/release/GetNovaVersionUpdateWorkflowContext.ps1 +++ b/src/private/release/GetNovaVersionUpdateWorkflowContext.ps1 @@ -3,11 +3,13 @@ function Get-NovaVersionUpdateWorkflowContext { param( [Parameter(Mandatory)][string]$ProjectRoot, [switch]$PreviewRelease, - [switch]$ContinuousIntegrationRequested + [switch]$ContinuousIntegrationRequested, + [switch]$OverrideWarningRequested ) $projectInfo = Get-NovaProjectInfo -Path $ProjectRoot $commitMessages = @(Get-GitCommitMessageForVersionBump -ProjectRoot $ProjectRoot) + Assert-NovaVersionBumpInferenceAvailability -ProjectRoot $ProjectRoot -CommitMessages $commitMessages -OverrideWarningRequested:$OverrideWarningRequested $label = Get-NovaVersionLabelForBump -ProjectRoot $ProjectRoot -CommitMessages $commitMessages -ContinuousIntegrationRequested:$ContinuousIntegrationRequested $labelResolution = Get-NovaVersionUpdateLabelResolution -ProjectInfo $projectInfo -Label $label -PreviewRelease:$PreviewRelease $versionUpdatePlan = Get-NovaVersionUpdatePlan -ProjectInfo $projectInfo -Label $labelResolution.EffectiveLabel -PreviewRelease:$PreviewRelease @@ -15,6 +17,40 @@ function Get-NovaVersionUpdateWorkflowContext { return Get-NovaVersionUpdateWorkflowContextObject -ProjectRoot $ProjectRoot -ProjectInfo $projectInfo -CommitMessages $commitMessages -Label $label -EffectiveLabel $labelResolution.EffectiveLabel -AdvisoryMessage $labelResolution.AdvisoryMessage -VersionUpdatePlan $versionUpdatePlan -PreviewRelease:$PreviewRelease -ContinuousIntegrationRequested:$ContinuousIntegrationRequested } +function Assert-NovaVersionBumpInferenceAvailability { + [CmdletBinding()] + param( + [Parameter(Mandatory)][string]$ProjectRoot, + [AllowEmptyCollection()][string[]]$CommitMessages = @(), + [switch]$OverrideWarningRequested + ) + + if ($CommitMessages.Count -gt 0) { + return + } + + if (Test-GitRepositoryIsAvailable -ProjectRoot $ProjectRoot) { + return + } + + $message = Get-NovaVersionBumpInferenceUnavailableMessage + Write-Warning $message + + if ($OverrideWarningRequested) { + Write-Verbose 'Continuing version bump because OverrideWarning was specified and Git-based bump inference is unavailable.' + return + } + + Stop-NovaOperation -Message $message -ErrorId 'Nova.Workflow.VersionBumpInferenceUnavailable' -Category InvalidOperation -TargetObject $ProjectRoot +} + +function Get-NovaVersionBumpInferenceUnavailableMessage { + [CmdletBinding()] + param() + + 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.' +} + function Get-NovaVersionUpdateLabelResolution { [CmdletBinding()] param( diff --git a/src/public/UpdateNovaModuleVersion.ps1 b/src/public/UpdateNovaModuleVersion.ps1 index 1a639c34..168c8115 100644 --- a/src/public/UpdateNovaModuleVersion.ps1 +++ b/src/public/UpdateNovaModuleVersion.ps1 @@ -3,7 +3,8 @@ function Update-NovaModuleVersion { param( [string]$Path = (Get-Location).Path, [switch]$Preview, - [switch]$ContinuousIntegration + [switch]$ContinuousIntegration, + [switch]$OverrideWarning ) $projectRoot = (Resolve-Path -LiteralPath $Path).Path @@ -12,7 +13,7 @@ function Update-NovaModuleVersion { return $ciActivation.Result } - $workflowContext = Get-NovaVersionUpdateWorkflowContext -ProjectRoot $projectRoot -PreviewRelease:$Preview -ContinuousIntegrationRequested:$ContinuousIntegration + $workflowContext = Get-NovaVersionUpdateWorkflowContext -ProjectRoot $projectRoot -PreviewRelease:$Preview -ContinuousIntegrationRequested:$ContinuousIntegration -OverrideWarningRequested:$OverrideWarning $shouldRun = $PSCmdlet.ShouldProcess($workflowContext.Target, $workflowContext.Action) $result = Invoke-NovaVersionUpdateWorkflow -WorkflowContext $workflowContext -ShouldRun:$shouldRun -WhatIfEnabled:$WhatIfPreference if ($null -eq $result) { @@ -23,4 +24,3 @@ function Update-NovaModuleVersion { return $result } - diff --git a/src/resources/cli/help/bump.psd1 b/src/resources/cli/help/bump.psd1 index d10821f4..f562917c 100644 --- a/src/resources/cli/help/bump.psd1 +++ b/src/resources/cli/help/bump.psd1 @@ -7,6 +7,7 @@ '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.', 'Set 1.0.0 manually once the software is stable. After that, nova bump can increment major versions normally.', 'Use --preview when you want an explicit prerelease iteration instead of the next stable semantic version.', + 'When Git-based bump inference is unavailable, nova bump stops unless you opt in to the Patch fallback with --override-warning.', 'For more information, documentation, and examples, visit:', 'https://www.novamoduletools.com/versioning-and-updates.html#bump' ) @@ -40,6 +41,12 @@ Long = '--continuous-integration' Placeholder = '' Description = 'Re-import the built dist module before the version bump workflow starts so later CI steps keep using the correct built module state.' + }, + @{ + Short = '-o' + Long = '--override-warning' + Placeholder = '' + Description = 'Allow an intentional Patch fallback when Git-based bump inference is unavailable, for example in example or template flows outside a Git repository.' } ) Examples = @( @@ -58,6 +65,10 @@ @{ Command = 'nova bump --continuous-integration --what-if' Description = 'Preview the next version by using the CI-safe routed bump entrypoint without changing project.json.' + }, + @{ + Command = 'nova bump --override-warning --what-if' + Description = 'Preview the explicit Patch fallback when Git-based bump inference is unavailable outside a Git repository.' } ) } diff --git a/tests/CoverageGaps.Cli.TestSupport.ps1 b/tests/CoverageGaps.Cli.TestSupport.ps1 index f180f923..18347f5d 100644 --- a/tests/CoverageGaps.Cli.TestSupport.ps1 +++ b/tests/CoverageGaps.Cli.TestSupport.ps1 @@ -81,6 +81,8 @@ function Get-TestNovaCliRoutedParserCaseList { @{Arguments = @('-p'); Property = 'Preview'} @{Arguments = @('--continuous-integration'); Property = 'ContinuousIntegration'} @{Arguments = @('-i'); Property = 'ContinuousIntegration'} + @{Arguments = @('--override-warning'); Property = 'OverrideWarning'} + @{Arguments = @('-o'); Property = 'OverrideWarning'} ) } @{ diff --git a/tests/CoverageGaps.ReleaseInternals.Tests.ps1 b/tests/CoverageGaps.ReleaseInternals.Tests.ps1 index 83ffcbfb..71cbef5f 100644 --- a/tests/CoverageGaps.ReleaseInternals.Tests.ps1 +++ b/tests/CoverageGaps.ReleaseInternals.Tests.ps1 @@ -651,6 +651,42 @@ Describe 'Coverage gaps for release and git internals' { } } + It 'Assert-NovaVersionBumpInferenceAvailability throws a clear error when Git-based bump inference is unavailable' { + InModuleScope $script:moduleName { + $projectRoot = Join-Path $TestDrive 'no-git-project-for-override-guard' + New-Item -ItemType Directory -Path $projectRoot -Force | Out-Null + + $warningMessages = @() + $thrown = $null + try { + Assert-NovaVersionBumpInferenceAvailability -ProjectRoot $projectRoot -CommitMessages @() -WarningVariable warningMessages + } + catch { + $thrown = $_ + } + + $thrown | Should -Not -BeNullOrEmpty + $thrown.Exception.Message | Should -Be '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.' + $thrown.FullyQualifiedErrorId | Should -Be 'Nova.Workflow.VersionBumpInferenceUnavailable' + $thrown.CategoryInfo.Category | Should -Be ([System.Management.Automation.ErrorCategory]::InvalidOperation) + $thrown.TargetObject | Should -Be $projectRoot + ($warningMessages -join [Environment]::NewLine) | Should -Match '-OverrideWarning / --override-warning / -o' + } + } + + It 'Assert-NovaVersionBumpInferenceAvailability warns but continues when OverrideWarningRequested is set' { + InModuleScope $script:moduleName { + $projectRoot = Join-Path $TestDrive 'no-git-project-for-override-continue' + New-Item -ItemType Directory -Path $projectRoot -Force | Out-Null + + $records = @(& {Assert-NovaVersionBumpInferenceAvailability -ProjectRoot $projectRoot -CommitMessages @() -OverrideWarningRequested} 3>&1) + + { $null = $records } | Should -Not -Throw + @($records | Where-Object {$_ -is [System.Management.Automation.WarningRecord]}).Count | Should -Be 1 + (@($records | Where-Object {$_ -is [System.Management.Automation.WarningRecord]} | ForEach-Object Message) -join [Environment]::NewLine) | Should -Match 'Cannot infer the version bump label from Git history' + } + } + It 'Get-GitCommitMessageForVersionBump uses the shared git adapter to resolve tagged commit history' { InModuleScope $script:moduleName { $projectRoot = Join-Path $TestDrive 'mocked-git-history' diff --git a/tests/NovaCommandModel.BumpAndCli.Tests.ps1 b/tests/NovaCommandModel.BumpAndCli.Tests.ps1 index 466f46de..2f4d9eca 100644 --- a/tests/NovaCommandModel.BumpAndCli.Tests.ps1 +++ b/tests/NovaCommandModel.BumpAndCli.Tests.ps1 @@ -352,6 +352,24 @@ Describe 'Nova command model - bump and CLI confirmation behavior' { } } + It 'Update-NovaModuleVersion forwards OverrideWarning into the version-update workflow context' { + InModuleScope $script:moduleName { + Mock Get-NovaVersionUpdateWorkflowContext { + [pscustomobject]@{ + Target = 'project.json' + Action = 'Update module version using Minor release label' + } + } + Mock Invoke-NovaVersionUpdateWorkflow { + [pscustomobject]@{NewVersion = '1.1.0'; Applied = $false} + } + + $null = Update-NovaModuleVersion -Path (Get-Location).Path -OverrideWarning -WhatIf + + Assert-MockCalled Get-NovaVersionUpdateWorkflowContext -Times 1 -ParameterFilter {$OverrideWarningRequested} + } + } + It 'Update-NovaModuleVersion writes the initial-development warning for stable 0.y.z breaking-change bumps' { Assert-TestUpdateNovaModuleVersionMajorZeroWarning -ModuleName $script:moduleName -TestCase @{ PreviousVersion = '0.1.0' @@ -572,7 +590,7 @@ Describe 'Nova command model - bump and CLI confirmation behavior' { } } - It 'Update-NovaModuleVersion -WhatIf falls back to a Patch preview when the project is not a git repository' { + It 'Update-NovaModuleVersion -WhatIf requires OverrideWarning when the project is not a git repository' { InModuleScope $script:moduleName { $projectRoot = Join-Path $TestDrive 'no-git-bump-project' New-Item -ItemType Directory -Path $projectRoot -Force | Out-Null @@ -592,12 +610,52 @@ Describe 'Nova command model - bump and CLI confirmation behavior' { } Mock Set-NovaModuleVersion {} - $result = Update-NovaModuleVersion -Path $projectRoot -WhatIf + $warningMessages = @() + $thrown = $null + try { + Update-NovaModuleVersion -Path $projectRoot -WhatIf -WarningVariable warningMessages + } + catch { + $thrown = $_ + } + + $thrown | Should -Not -BeNullOrEmpty + $thrown.Exception.Message | Should -Be '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.' + $thrown.FullyQualifiedErrorId | Should -Be 'Nova.Workflow.VersionBumpInferenceUnavailable' + ($warningMessages -join [Environment]::NewLine) | Should -Match '-OverrideWarning / --override-warning / -o' + Assert-MockCalled Get-NovaVersionUpdatePlan -Times 0 + Assert-MockCalled Set-NovaModuleVersion -Times 0 + } + } + + It 'Update-NovaModuleVersion -WhatIf continues with a Patch fallback when OverrideWarning is specified outside a git repository' { + InModuleScope $script:moduleName { + $projectRoot = Join-Path $TestDrive 'no-git-bump-project-with-override' + New-Item -ItemType Directory -Path $projectRoot -Force | Out-Null + + Mock Get-NovaProjectInfo { + [pscustomobject]@{ + Version = '1.0.0' + ProjectJSON = (Join-Path $projectRoot 'project.json') + } + } + Mock Get-NovaVersionUpdatePlan { + [pscustomobject]@{ + ProjectFile = (Join-Path $projectRoot 'project.json') + CurrentVersion = [semver]'1.0.0' + NewVersion = [semver]'1.0.1' + } + } + Mock Set-NovaModuleVersion {} + + $warningMessages = @() + $result = Update-NovaModuleVersion -Path $projectRoot -OverrideWarning -WhatIf -WarningVariable warningMessages $result.PreviousVersion | Should -Be '1.0.0' $result.NewVersion | Should -Be '1.0.1' $result.Label | Should -Be 'Patch' $result.CommitCount | Should -Be 0 + ($warningMessages -join [Environment]::NewLine) | Should -Match 'Cannot infer the version bump label from Git history' Assert-MockCalled Set-NovaModuleVersion -Times 0 } } diff --git a/tests/NovaCommandModel.StandaloneCli.OverrideWarning.Tests.ps1 b/tests/NovaCommandModel.StandaloneCli.OverrideWarning.Tests.ps1 index d76264de..b3859170 100644 --- a/tests/NovaCommandModel.StandaloneCli.OverrideWarning.Tests.ps1 +++ b/tests/NovaCommandModel.StandaloneCli.OverrideWarning.Tests.ps1 @@ -62,6 +62,7 @@ BeforeAll { Describe 'Nova command model - standalone CLI override-warning behavior' { It 'Invoke-NovaCli forwards override-warning for routed build-aware commands' -ForEach @( @{CommandName = 'build'; ActionCommand = 'Invoke-NovaBuild'; Arguments = @('--override-warning')} + @{CommandName = 'bump'; ActionCommand = 'Update-NovaModuleVersion'; Arguments = @('--override-warning')} @{CommandName = 'test'; ActionCommand = 'Test-NovaBuild'; Arguments = @('--build', '--override-warning')} @{CommandName = 'package'; ActionCommand = 'New-NovaModulePackage'; Arguments = @('--override-warning')} @{CommandName = 'publish'; ActionCommand = 'Publish-NovaModule'; Arguments = @('--repository', 'PSGallery', '--api-key', 'key123', '--override-warning')} diff --git a/tests/NovaCommandModel.StandaloneCli.Tests.ps1 b/tests/NovaCommandModel.StandaloneCli.Tests.ps1 index 2e5cc946..1f2e5ca5 100644 --- a/tests/NovaCommandModel.StandaloneCli.Tests.ps1 +++ b/tests/NovaCommandModel.StandaloneCli.Tests.ps1 @@ -605,6 +605,20 @@ Describe '$projectName tests' { } } + It 'Invoke-NovaCli help for bump documents the override-warning options' -ForEach @( + @{CommandName = 'bump'} + ) { + InModuleScope $script:moduleName -Parameters @{CommandName = $_.CommandName} { + param($CommandName) + + $shortHelp = Invoke-NovaCli -Command $CommandName -Arguments @('--help') + $longHelp = Invoke-NovaCli -Command '--help' -Arguments @($CommandName) + + $shortHelp | Should -Match '-o, --override-warning' + $longHelp | Should -Match '--override-warning' + } + } + It 'Invoke-NovaCli CLI help never delegates to PowerShell Get-Help' { InModuleScope $script:moduleName { Mock Get-Help {throw 'CLI help should not call Get-Help'}