@@ -49,7 +49,7 @@ for ($i = 0; $i -lt $lines.Count; $i++)
4949 break
5050}
5151
52- # Make sure that there's a the requested section header
52+ # Make sure that there's the requested section header
5353:outer for ($i = 0 ; $i -lt $lines.Count ; $i ++ )
5454{
5555 $line = $lines [$i ]
@@ -115,9 +115,9 @@ $PullRequestMD = "[#$($PR | Split-Path -Leaf)]($PR)"
115115$updated = $false
116116for ($i = 0 ; $i -lt $sectionEnd ; $i ++ )
117117{
118- if (($lines [$i ] -match " ^- Bump $Name .*to" ) -and `
119- ($lines [$i + 1 ] -match " ^ - \[changelog\]\($RepoUrl " ) -and `
120- ($lines [$i + 2 ] -match " ^ - \[diff\]\($RepoUrl " ))
118+ if (($lines [$i ] -match " ^[-*] Bump $Name .*to" ) -and `
119+ ($lines [$i + 1 ] -match " ^ [-*] \[changelog\]\($RepoUrl " ) -and `
120+ ($lines [$i + 2 ] -match " ^ [-*] \[diff\]\($RepoUrl " ))
121121 {
122122 Write-Host " Found an existing changelog entry at $ ( $i ) :"
123123 Write-Host " " , $lines [$i ]
@@ -126,7 +126,7 @@ for ($i = 0; $i -lt $sectionEnd; $i++)
126126
127127 $lines [$i ] = $lines [$i ] -replace " (Bump $Name .*)to .* \(" , " `$ 1to $newTagNice ("
128128 $lines [$i ] = $lines [$i ] -replace " \)$" , " , $PullRequestMD )"
129- $lines [$i + 1 ] = " - [changelog]( $RepoUrl /blob/ $MainBranch /CHANGELOG.md #$tagAnchor )"
129+ $lines [$i + 1 ] = $lines [ $i + 1 ] -replace " #.*\) " , " #$tagAnchor )"
130130 $lines [$i + 2 ] = $lines [$i + 2 ] -replace " \.\.\..*\)$" , " ...$NewTag )"
131131
132132 Write-Host " Updating the entry to: "
@@ -140,9 +140,13 @@ for ($i = 0; $i -lt $sectionEnd; $i++)
140140
141141if (! $updated )
142142{
143- $entry = @ (" - Bump $Name from $oldTagNice to $newTagNice ($PullRequestMD )" ,
144- " - [changelog]($RepoUrl /blob/$MainBranch /CHANGELOG.md#$tagAnchor )" ,
145- " - [diff]($RepoUrl /compare/$OldTag ...$NewTag )" )
143+ # Find what character is used as a bullet-point separator - look for the first bullet-point object that wasn't created by this script.
144+ $bulletPoint = $lines | Where-Object { ($_ -match " ^ *[-*] " ) -and -not ($_ -match " (Bump .* to|\[changelog\]|\[diff\])" ) } | Select-Object - First 1
145+ $bulletPoint = " $bulletPoint -" [0 ]
146+
147+ $entry = @ (" $bulletPoint Bump $Name from $oldTagNice to $newTagNice ($PullRequestMD )" ,
148+ " $bulletPoint [changelog]($RepoUrl /blob/$MainBranch /CHANGELOG.md#$tagAnchor )" ,
149+ " $bulletPoint [diff]($RepoUrl /compare/$OldTag ...$NewTag )" )
146150
147151 Write-Host " Adding a changelog entry at line $ ( $sectionEnd ) :"
148152 foreach ($line in $entry )
0 commit comments