44 [Parameter (Mandatory = $true )][string ] $RepoUrl ,
55 [Parameter (Mandatory = $true )][string ] $MainBranch ,
66 [Parameter (Mandatory = $true )][string ] $OldTag ,
7- [Parameter (Mandatory = $true )][string ] $NewTag
7+ [Parameter (Mandatory = $true )][string ] $NewTag ,
8+ [Parameter (Mandatory = $true )][string ] $Section
89)
910
1011Set-StrictMode - Version latest
@@ -48,7 +49,7 @@ for ($i = 0; $i -lt $lines.Count; $i++)
4849 break
4950}
5051
51- # Make sure that there's a `Features` header
52+ # Make sure that there's a the requested section header
5253:outer for ($i = 0 ; $i -lt $lines.Count ; $i ++ )
5354{
5455 $line = $lines [$i ]
@@ -62,12 +63,12 @@ for ($i = 0; $i -lt $lines.Count; $i++)
6263 # Next, we expect a header
6364 if (-not $line.StartsWith (" #" ))
6465 {
65- throw " Unexpected changelog line - expecting a section header at this point, such as '### Features ', but found: '$line '"
66+ throw " Unexpected changelog line - expecting a section header at this point, such as '### $Section ', but found: '$line '"
6667 }
6768
68- if (-not ($line -match " features " ))
69+ if (-not ($line -match $Section ))
6970 {
70- # If it's a version-specific section header but not "Features" , skip all the items in this section
71+ # If it's a version-specific section header but not the requested section header , skip all the items in this section
7172 if ($line.StartsWith (" ###" ))
7273 {
7374 for ($i = $i + 1 ; $i -lt $lines.Count - 1 ; $i ++ )
@@ -79,29 +80,29 @@ for ($i = 0; $i -lt $lines.Count; $i++)
7980 }
8081 }
8182
82- # add Features as the first sub-header
83- Write-Host " Adding a new '### Features ' section at line $i "
84- $lines = $lines [0 .. ($i - 1 )] + @ (" ### Features " , " " , " " ) + $lines [$i .. ($lines.Count - 1 )]
83+ # add the section header as the first sub-header
84+ Write-Host " Adding a new '### $Section ' section at line $i "
85+ $lines = $lines [0 .. ($i - 1 )] + @ (" ### $Section " , " " , " " ) + $lines [$i .. ($lines.Count - 1 )]
8586 }
8687 break
8788}
8889
89- # Find the last point in the first `Features` header
90+ # Find the last point in the first requested section header
9091for ($i = 0 ; $i -lt $lines.Count ; $i ++ )
9192{
9293 $line = $lines [$i ]
93- if ($line -match " Features " )
94+ if ($line -match $Section )
9495 {
95- Write-Host " Found a Features header at $i "
96+ Write-Host " Found a $Section header at $i "
9697 # Find the next header and then go backward until we find a non-empty line
9798 for ($i ++ ; $i -lt $lines.Count -and -not $lines [$i ].StartsWith(" #" ); $i ++ ) {}
9899 for ($i -- ; $i -gt 0 -and $lines [$i ].Trim().Length -eq 0 ; $i -- ) {}
99- $i += ($lines [$i ] -match " Features " ) ? 2 : 1
100+ $i += ($lines [$i ] -match $Section ) ? 2 : 1
100101 break
101102 }
102103}
103104
104- # What line we want to insert at - the empty line at the end of the currently unreleased Features section.
105+ # What line we want to insert at - the empty line at the end of the currently unreleased section.
105106$sectionEnd = $i
106107
107108$tagAnchor = $NewTag.Replace (' .' , ' ' )
@@ -110,7 +111,7 @@ $newTagNice = ($NewTag -match "^[0-9]") ? "v$NewTag" : $NewTag
110111
111112$PullRequestMD = " [#$ ( $PR | Split-Path - Leaf) ]($PR )"
112113
113- # First check if an existing entry for the same dependency exists among unreleased features - if so, update it instead of adding a new one.
114+ # First check if an existing entry for the same dependency exists among unreleased $Section - if so, update it instead of adding a new one.
114115$updated = $false
115116for ($i = 0 ; $i -lt $sectionEnd ; $i ++ )
116117{
0 commit comments