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

Feat: support prettier Comments on Changelog.md when updating a dependency. #75

Merged
merged 7 commits into from
Oct 16, 2024
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
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.
lucas-zimerman marked this conversation as resolved.
Show resolved Hide resolved
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))
Loading