Skip to content

Commit

Permalink
Feat: support prettier Comments on Changelog.md when updating a depen…
Browse files Browse the repository at this point in the history
…dency. (#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]>
  • Loading branch information
lucas-zimerman and vaind authored Oct 16, 2024
1 parent ab746b0 commit 1a3125e
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## Unreleased

### Features

- Add support for prettier-ignore notes on `CHANGELOG.md` ([#75](https://github.com/getsentry/github-workflows/pull/75))

Example of notes before `## Unreleased` Header on `CHANGELOG.md`

<!-- prettier-ignore-start -->
> [!IMPORTANT]
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
<!-- prettier-ignore-end -->
## 2.10.0

### Changes
Expand Down
41 changes: 40 additions & 1 deletion updater/scripts/update-changelog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,36 @@ Write-Host "Found changelog: $file"

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

$skippingComment = $false

# Make sure that there's an `Unreleased` header
for ($i = 0; $i -lt $lines.Count; $i++)
{
$line = $lines[$i]

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

# Skip the prettier comment that may be found before the Unreleased version.
if ($line -match "<!-- prettier-ignore-start -->" -and -not $skippingComment)
{
$skippingComment = $true
continue
}
if ($skippingComment) {
if ($line -match "<!-- prettier-ignore-end -->") {
$skippingComment = $false
continue
}
if ($line -match "^> ") {
continue
}
throw "Prettier comment format - expected <!-- prettier-ignore-end -->, but found: '$line'"
}
# End of prettier comment

# Next, we expect a header for the current version or "Unreleased".
if (-not $line.StartsWith("#"))
{
Expand All @@ -60,6 +79,26 @@ for ($i = 0; $i -lt $lines.Count; $i++)
continue
}

# Skip the prettier comment that may be found before the Unreleased version.
if ($line -match "<!-- prettier-ignore-start -->" -and -not $skippingComment)
{
$skippingComment = $true
continue
}
if ($skippingComment) {

if ($line -match "<!-- prettier-ignore-end -->") {
$skippingComment = $false
continue
}
if ($line -match "^> ") {
continue
}
throw "Prettier comment format - expected <!-- prettier-ignore-end -->, but found: '$line'"
}
# End of prettier comment


# Next, we expect a header
if (-not $line.StartsWith("#"))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

<!-- prettier-ignore-start -->
> [!IMPORTANT]
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Dependencies

- Following items preserve their bullet points as-is even through an update
* Bump Dependency to v7.17.0 ([#100](https://github.com/getsentry/dependant/pulls/100), [#123](https://github.com/getsentry/dependant/pulls/123))
* [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#7170)
- [diff](https://github.com/getsentry/dependency/compare/5.0.0...7.17.0)

## 0.14.0

### Dependencies

- Capture `Debug.LogError()` and `Debug.LogException()` also on background threads ([#673](https://github.com/getsentry/sentry-unity/pull/673))
- Adding override for Sentry CLI URL ([#666](https://github.com/getsentry/sentry-unity/pull/666))
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

<!-- prettier-ignore-start -->
> [!IMPORTANT]
> If you are upgrading to the `1.x` versions of the Sentry SDK from `0.x` or below,
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/SDK/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Dependencies

- Following items preserve their bullet points as-is even through an update
* Bump Dependency to v6.0.0 ([#100](https://github.com/getsentry/dependant/pulls/100))
* [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#600)
- [diff](https://github.com/getsentry/dependency/compare/5.0.0...6.0.0)

## 0.14.0

### Dependencies

- Capture `Debug.LogError()` and `Debug.LogException()` also on background threads ([#673](https://github.com/getsentry/sentry-unity/pull/673))
- Adding override for Sentry CLI URL ([#666](https://github.com/getsentry/sentry-unity/pull/666))

0 comments on commit 1a3125e

Please sign in to comment.