Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changelog section parsing #25

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
### Fixes

- Preserve changelog bullet-point format ([#20](https://github.com/getsentry/github-workflows/pull/20))
- Changelog section parsing when an entry text contains the section name in the text ([#25](https://github.com/getsentry/github-workflows/pull/25))

## 1.0.0

Expand Down
6 changes: 3 additions & 3 deletions scripts/update-changelog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ for ($i = 0; $i -lt $lines.Count; $i++)
throw "Unexpected changelog line - expecting a section header at this point, such as '### $Section', but found: '$line'"
}

if (-not ($line -match $Section))
if (-not ($line -match "### $Section"))
{
# If it's a version-specific section header but not the requested section header, skip all the items in this section
if ($line.StartsWith("###"))
Expand All @@ -91,13 +91,13 @@ for ($i = 0; $i -lt $lines.Count; $i++)
for ($i = 0; $i -lt $lines.Count; $i++)
{
$line = $lines[$i]
if ($line -match $Section)
if ($line -match "### $Section")
{
Write-Host "Found a $Section header at $i"
# Find the next header and then go backward until we find a non-empty line
for ($i++; $i -lt $lines.Count -and -not $lines[$i].StartsWith("#"); $i++) {}
for ($i--; $i -gt 0 -and $lines[$i].Trim().Length -eq 0; $i--) {}
$i += ($lines[$i] -match $Section) ? 2 : 1
$i += ($lines[$i] -match "### $Section") ? 2 : 1
break
}
}
Expand Down