Skip to content

Commit 45bc4f7

Browse files
vaindclaude
andauthored
fix: Improve bullet-point resolution when plain text precedes bullet points (#123)
* fix: Improve bullet-point resolution when plain text precedes bullet points The update-changelog script failed to detect bullet point formats when changelogs contained plain introductory text before any bullet points, causing incorrectly formatted entries with missing dashes. Fixed by improving the bullet-point detection logic to properly extract bullet characters and handle edge cases when no bullet points are found. Fixes #120 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: Add changelog entry for bullet-point resolution fix 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix tests on windows --------- Co-authored-by: Claude <[email protected]>
1 parent 5f024a8 commit 45bc4f7

File tree

5 files changed

+124
-4
lines changed

5 files changed

+124
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ To update your existing Danger workflows:
5757

5858
### Fixes
5959

60+
- Updater - Fix bullet-point resolution when plain text precedes bullet points ([#123](https://github.com/getsentry/github-workflows/pull/123))
6061
- Improve changelog generation for non-tagged commits and edge cases ([#115](https://github.com/getsentry/github-workflows/pull/115))
6162

6263
## 2.14.1

updater/scripts/update-changelog.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ for ($i = 0; $i -lt $lines.Count; $i++)
9797
throw "Prettier comment format - expected <!-- prettier-ignore-end -->, but found: '$line'"
9898
}
9999
# End of prettier comment
100-
101100

102101
# Next, we expect a header
103102
if (-not $line.StartsWith("#"))
@@ -180,9 +179,8 @@ for ($i = 0; $i -lt $sectionEnd; $i++)
180179
if (!$updated)
181180
{
182181
# Find what character is used as a bullet-point separator - look for the first bullet-point object that wasn't created by this script.
183-
$bulletPoint = $lines | Where-Object { ($_ -match "^ *[-*] ") -and -not ($_ -match "(Bump .* to|\[changelog\]|\[diff\])") } | Select-Object -First 1
184-
$bulletPoint = "$bulletPoint-"[0]
185-
182+
$bulletPoint = $lines | Where-Object { ($_ -match '^ *[-*] ') -and -not ($_ -match '(Bump .* to|\[changelog\]|\[diff\])') } | Select-Object -First 1
183+
$bulletPoint = "$($bulletPoint.Trim())-"[0]
186184
$entry = @("$bulletPoint Bump $Name from $oldTagNice to $newTagNice ($PullRequestMD)",
187185
" $bulletPoint [changelog]($RepoUrl/blob/$MainBranch/CHANGELOG.md#$tagAnchor)",
188186
" $bulletPoint [diff]($RepoUrl/compare/$OldTag...$NewTag)")
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
### Breaking Changes
6+
7+
Updater and Danger reusable workflows are now composite actions ([#114](https://github.com/getsentry/github-workflows/pull/114))
8+
9+
To update your existing Updater workflows:
10+
```yaml
11+
### Before
12+
native:
13+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
14+
with:
15+
path: scripts/update-sentry-native-ndk.sh
16+
name: Native SDK
17+
secrets:
18+
# If a custom token is used instead, a CI would be triggered on a created PR.
19+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
20+
21+
### After
22+
native:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: getsentry/github-workflows/updater@v3
26+
with:
27+
path: scripts/update-sentry-native-ndk.sh
28+
name: Native SDK
29+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
30+
```
31+
32+
To update your existing Danger workflows:
33+
```yaml
34+
### Before
35+
danger:
36+
uses: getsentry/github-workflows/.github/workflows/danger.yml@v2
37+
38+
### After
39+
danger:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: getsentry/github-workflows/danger@v3
43+
```
44+
45+
### Dependencies
46+
47+
- Bump Dependency from v7.16.0 to v7.17.0 ([#123](https://github.com/getsentry/dependant/pulls/123))
48+
- [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#7170)
49+
- [diff](https://github.com/getsentry/dependency/compare/7.16.0...7.17.0)
50+
51+
## 2.14.1
52+
53+
### Features
54+
55+
- Do something ([#100](https://github.com/getsentry/dependant/pulls/100))
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
### Breaking Changes
6+
7+
Updater and Danger reusable workflows are now composite actions ([#114](https://github.com/getsentry/github-workflows/pull/114))
8+
9+
To update your existing Updater workflows:
10+
```yaml
11+
### Before
12+
native:
13+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
14+
with:
15+
path: scripts/update-sentry-native-ndk.sh
16+
name: Native SDK
17+
secrets:
18+
# If a custom token is used instead, a CI would be triggered on a created PR.
19+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
20+
21+
### After
22+
native:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: getsentry/github-workflows/updater@v3
26+
with:
27+
path: scripts/update-sentry-native-ndk.sh
28+
name: Native SDK
29+
api-token: ${{ secrets.CI_DEPLOY_KEY }}
30+
```
31+
32+
To update your existing Danger workflows:
33+
```yaml
34+
### Before
35+
danger:
36+
uses: getsentry/github-workflows/.github/workflows/danger.yml@v2
37+
38+
### After
39+
danger:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: getsentry/github-workflows/danger@v3
43+
```
44+
45+
## 2.14.1
46+
47+
### Features
48+
49+
- Do something ([#100](https://github.com/getsentry/dependant/pulls/100))

updater/tests/update-changelog.Tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,21 @@ Describe 'update-changelog' {
1515

1616
Get-Content "$testCase/CHANGELOG.md" | Should -Be (Get-Content "$testCase/CHANGELOG.md.expected")
1717
}
18+
19+
It 'should correctly detect bullet points when plain text appears before bullet points' {
20+
$testCasePath = "$PSScriptRoot/testdata/changelog/plain-text-intro"
21+
Copy-Item "$testCasePath/CHANGELOG.md.original" "$testCasePath/CHANGELOG.md"
22+
23+
pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" `
24+
-Name 'Dependency' `
25+
-PR 'https://github.com/getsentry/dependant/pulls/123' `
26+
-RepoUrl 'https://github.com/getsentry/dependency' `
27+
-MainBranch 'main' `
28+
-OldTag '7.16.0' `
29+
-NewTag '7.17.0' `
30+
-Section 'Dependencies'
31+
32+
# verify the full output matches expected
33+
Get-Content "$testCasePath/CHANGELOG.md" | Should -Be (Get-Content "$testCasePath/CHANGELOG.md.expected")
34+
}
1835
}

0 commit comments

Comments
 (0)