Skip to content

Commit 1a3125e

Browse files
Feat: support prettier Comments on Changelog.md when updating a dependency. (#75)
* Add support for prettier ignore. * remove new item * changelog update * move logic after changelog check * revert original code * Apply suggestions from code review Co-authored-by: Ivan Dlugos <[email protected]> * fix changelog and script test --------- Co-authored-by: Ivan Dlugos <[email protected]>
1 parent ab746b0 commit 1a3125e

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Add support for prettier-ignore notes on `CHANGELOG.md` ([#75](https://github.com/getsentry/github-workflows/pull/75))
8+
9+
Example of notes before `## Unreleased` Header on `CHANGELOG.md`
10+
11+
<!-- prettier-ignore-start -->
12+
> [!IMPORTANT]
13+
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
14+
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
15+
<!-- prettier-ignore-end -->
16+
317
## 2.10.0
418

519
### Changes

updater/scripts/update-changelog.ps1

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,36 @@ Write-Host "Found changelog: $file"
2323

2424
[string[]]$lines = Get-Content $file
2525

26+
$skippingComment = $false
27+
2628
# Make sure that there's an `Unreleased` header
2729
for ($i = 0; $i -lt $lines.Count; $i++)
2830
{
2931
$line = $lines[$i]
3032

31-
# Skip the "Changelog" header and empty lines at the beginning.
3233
if ($line -match "changelog" -or $line.Trim().Length -eq 0)
3334
{
3435
continue
3536
}
3637

38+
# Skip the prettier comment that may be found before the Unreleased version.
39+
if ($line -match "<!-- prettier-ignore-start -->" -and -not $skippingComment)
40+
{
41+
$skippingComment = $true
42+
continue
43+
}
44+
if ($skippingComment) {
45+
if ($line -match "<!-- prettier-ignore-end -->") {
46+
$skippingComment = $false
47+
continue
48+
}
49+
if ($line -match "^> ") {
50+
continue
51+
}
52+
throw "Prettier comment format - expected <!-- prettier-ignore-end -->, but found: '$line'"
53+
}
54+
# End of prettier comment
55+
3756
# Next, we expect a header for the current version or "Unreleased".
3857
if (-not $line.StartsWith("#"))
3958
{
@@ -60,6 +79,26 @@ for ($i = 0; $i -lt $lines.Count; $i++)
6079
continue
6180
}
6281

82+
# Skip the prettier comment that may be found before the Unreleased version.
83+
if ($line -match "<!-- prettier-ignore-start -->" -and -not $skippingComment)
84+
{
85+
$skippingComment = $true
86+
continue
87+
}
88+
if ($skippingComment) {
89+
90+
if ($line -match "<!-- prettier-ignore-end -->") {
91+
$skippingComment = $false
92+
continue
93+
}
94+
if ($line -match "^> ") {
95+
continue
96+
}
97+
throw "Prettier comment format - expected <!-- prettier-ignore-end -->, but found: '$line'"
98+
}
99+
# End of prettier comment
100+
101+
63102
# Next, we expect a header
64103
if (-not $line.StartsWith("#"))
65104
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
<!-- prettier-ignore-start -->
4+
> [!IMPORTANT]
5+
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
6+
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
7+
<!-- prettier-ignore-end -->
8+
9+
## Unreleased
10+
11+
### Dependencies
12+
13+
- Following items preserve their bullet points as-is even through an update
14+
* Bump Dependency to v7.17.0 ([#100](https://github.com/getsentry/dependant/pulls/100), [#123](https://github.com/getsentry/dependant/pulls/123))
15+
* [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#7170)
16+
- [diff](https://github.com/getsentry/dependency/compare/5.0.0...7.17.0)
17+
18+
## 0.14.0
19+
20+
### Dependencies
21+
22+
- Capture `Debug.LogError()` and `Debug.LogException()` also on background threads ([#673](https://github.com/getsentry/sentry-unity/pull/673))
23+
- Adding override for Sentry CLI URL ([#666](https://github.com/getsentry/sentry-unity/pull/666))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
<!-- prettier-ignore-start -->
4+
> [!IMPORTANT]
5+
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
6+
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
7+
<!-- prettier-ignore-end -->
8+
9+
## Unreleased
10+
11+
### Dependencies
12+
13+
- Following items preserve their bullet points as-is even through an update
14+
* Bump Dependency to v6.0.0 ([#100](https://github.com/getsentry/dependant/pulls/100))
15+
* [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#600)
16+
- [diff](https://github.com/getsentry/dependency/compare/5.0.0...6.0.0)
17+
18+
## 0.14.0
19+
20+
### Dependencies
21+
22+
- Capture `Debug.LogError()` and `Debug.LogException()` also on background threads ([#673](https://github.com/getsentry/sentry-unity/pull/673))
23+
- Adding override for Sentry CLI URL ([#666](https://github.com/getsentry/sentry-unity/pull/666))

0 commit comments

Comments
 (0)