forked from icsharpcode/CodeConverter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-LatestChangelog.ps1
More file actions
39 lines (32 loc) · 842 Bytes
/
Get-LatestChangelog.ps1
File metadata and controls
39 lines (32 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Param(
[string]$Path = 'CHANGELOG.md'
)
if (-not [System.IO.Path]::IsPathRooted($Path)) {
$Path = Join-Path $PSScriptRoot $Path
}
if (-not (Test-Path -Path $Path)) {
throw "Changelog not found at '$Path'."
}
$lines = Get-Content -Path $Path
$inSection = $false
$collected = New-Object System.Collections.Generic.List[string]
foreach ($line in $lines) {
if ($line -match '^## \[') {
if (-not $inSection) {
if ($line -match '^## \[Unreleased\]') {
continue
}
$inSection = $true
}
elseif ($inSection) {
break
}
}
if ($inSection) {
$collected.Add($line) | Out-Null
}
}
if (-not $inSection -or $collected.Count -eq 0) {
throw "No released changelog section found in '$Path'."
}
$collected | Write-Output