ChangelogManagement
ChangelogManagement copied to clipboard
`Get-ChangelogData`: Throws an exception if `Unreleased` header is misspelled
This line throws an error if the Unreleased is misspelled.
https://github.com/natescherer/ChangelogManagement/blob/7da86a37f98f9ecdf822c5cc02f86a7cd60dc979/src/public/Get-ChangelogData.ps1#L113
Having the change log like:
## [Unrelesed]
## [0.12.0] - 2022-12-10
### Added
- Something added
Calling this:
Get-ChangelogData -Path .\CHANGELOG.md
throws this:
Exception :
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : You cannot call a method on a null-valued expression.
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvokeMethodOnNull
InvocationInfo :
ScriptLineNumber : 113
OffsetInLine : 25
HistoryId : -1
ScriptName : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
Line : "Date" = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline)[0]
PositionMessage : At C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1:113 char:25
+ … "Date" = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public
PSCommandPath : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
CommandOrigin : Internal
ScriptStackTrace : at Get-ChangelogData, C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1: line 113
at <ScriptBlock>, <No file>: line 1
TargetSite : System.Object CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.Object)
Message : You cannot call a method on a null-valued expression.
Source : Anonymously Hosted DynamicMethods Assembly
HResult : -2146233087
StackTrace :
at CallSite.Target(Closure, CallSite, Object, Object)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at lambda_method2941(Closure, Object[], StrongBox`1[], InterpretedFrame)
CategoryInfo : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
InvocationInfo :
ScriptLineNumber : 113
OffsetInLine : 25
HistoryId : -1
ScriptName : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
Line : "Date" = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline)[0]
PositionMessage : At C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1:113 char:25
+ … "Date" = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public
PSCommandPath : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
CommandOrigin : Internal
ScriptStackTrace : at Get-ChangelogData, C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1: line 113
at <ScriptBlock>, <No file>: line 1
Having some level of document structure validation is probably a good idea rather than just assuming the doc matches KaC 1.0.0. I'll throw the general concept of document validation for Update-Changelog and Get-ChangelogData onto the todo pile.
Yeah, I think it just need to throw a better error message saying that header X does not conform to the expected format.