From e54d6cdcdf9e73abee502ce911c6aba51643ab27 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:11:51 -0300 Subject: [PATCH 1/7] Add support for prettier ignore. --- updater/scripts/update-changelog.ps1 | 22 +++++++++++++++++- .../CHANGELOG.md copy.original | 17 ++++++++++++++ .../update-with-comment/CHANGELOG.md.expected | 23 +++++++++++++++++++ .../update-with-comment/CHANGELOG.md.original | 23 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original create mode 100644 updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.expected create mode 100644 updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.original diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index 86d7d18a..af15d659 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -23,12 +23,32 @@ Write-Host "Found changelog: $file" [string[]]$lines = Get-Content $file +$skipPrettier = $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. + # Skip the prettier comment that may be found before the Unreleased version. + if ($line -match "" -and $skipPrettier -eq $false) + { + $skipPrettier = $true + continue + } + if ($skipPrettier) { + if ($line -match "\s*") { + $skipPrettier = $false + continue + } + if ($line -match "^> ") { + continue + } + throw "Prettier comment format - expected , but found: '$line'" + } + # End of prettier comment + + # . if ($line -match "changelog" -or $line.Trim().Length -eq 0) { continue diff --git a/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original b/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original new file mode 100644 index 00000000..e8d82608 --- /dev/null +++ b/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original @@ -0,0 +1,17 @@ +# Changelog + +## 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)) diff --git a/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.expected b/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.expected new file mode 100644 index 00000000..bf9c9cbb --- /dev/null +++ b/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.expected @@ -0,0 +1,23 @@ +# Changelog + + +> [!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. + + +## 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)) diff --git a/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.original b/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.original new file mode 100644 index 00000000..26c4d317 --- /dev/null +++ b/updater/tests/testdata/changelog/update-with-comment/CHANGELOG.md.original @@ -0,0 +1,23 @@ +# Changelog + + +> [!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. + + +## 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)) From 5e495d2d43503cef80d7905dbf9c0f8e32dc67ed Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:12:06 -0300 Subject: [PATCH 2/7] remove new item --- .../CHANGELOG.md copy.original | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original diff --git a/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original b/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original deleted file mode 100644 index e8d82608..00000000 --- a/updater/tests/testdata/changelog/new-second-section/CHANGELOG.md copy.original +++ /dev/null @@ -1,17 +0,0 @@ -# Changelog - -## 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)) From d271f47d3e7454e06f68a48cf7dc351c2fd741ef Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:14:08 -0300 Subject: [PATCH 3/7] changelog update --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea345692..747dd718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## Unreleased + +### Features + +- Add support for prettier-ignore notes on `CHANGELOG.md` + +Example of notes before `## Unreleased` Header on `CHANGELOG.md` + + +> [!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. + + ## 2.10.0 ### Changes From 0d7dd6c850e7b4ba98482dce8c7dbd0741ba5383 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:23:42 -0300 Subject: [PATCH 4/7] move logic after changelog check --- updater/scripts/update-changelog.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index af15d659..aa7a5697 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -30,6 +30,12 @@ for ($i = 0; $i -lt $lines.Count; $i++) { $line = $lines[$i] + # . + 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 "" -and $skipPrettier -eq $false) { @@ -48,12 +54,6 @@ for ($i = 0; $i -lt $lines.Count; $i++) } # End of prettier comment - # . - if ($line -match "changelog" -or $line.Trim().Length -eq 0) - { - continue - } - # Next, we expect a header for the current version or "Unreleased". if (-not $line.StartsWith("#")) { From 40f7ebd7b12f7c85390aba7a548f264899c98007 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:24:01 -0300 Subject: [PATCH 5/7] revert original code --- updater/scripts/update-changelog.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index aa7a5697..63f816b7 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -30,7 +30,6 @@ for ($i = 0; $i -lt $lines.Count; $i++) { $line = $lines[$i] - # . if ($line -match "changelog" -or $line.Trim().Length -eq 0) { continue From f6cc6c43912414f8b418371bc08f1a331b5c798f Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Oct 2024 16:34:50 -0300 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com> --- updater/scripts/update-changelog.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index 63f816b7..0d924272 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -36,7 +36,7 @@ for ($i = 0; $i -lt $lines.Count; $i++) } # Skip the prettier comment that may be found before the Unreleased version. - if ($line -match "" -and $skipPrettier -eq $false) + if ($line -match "" -and -not $skipPrettier) { $skipPrettier = $true continue @@ -51,7 +51,7 @@ for ($i = 0; $i -lt $lines.Count; $i++) } throw "Prettier comment format - expected , but found: '$line'" } - # End of prettier comment + # End of prettier comment # Next, we expect a header for the current version or "Unreleased". if (-not $line.StartsWith("#")) From a24459bb5bec6e754c40e0761311aad455f159c3 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 15 Oct 2024 17:01:33 -0300 Subject: [PATCH 7/7] fix changelog and script test --- CHANGELOG.md | 2 +- updater/scripts/update-changelog.ps1 | 32 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 747dd718..9c9a2ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Add support for prettier-ignore notes on `CHANGELOG.md` +- 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` diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index 0d924272..5c054e1e 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -23,7 +23,7 @@ Write-Host "Found changelog: $file" [string[]]$lines = Get-Content $file -$skipPrettier = $false +$skippingComment = $false # Make sure that there's an `Unreleased` header for ($i = 0; $i -lt $lines.Count; $i++) @@ -36,14 +36,14 @@ for ($i = 0; $i -lt $lines.Count; $i++) } # Skip the prettier comment that may be found before the Unreleased version. - if ($line -match "" -and -not $skipPrettier) + if ($line -match "" -and -not $skippingComment) { - $skipPrettier = $true + $skippingComment = $true continue } - if ($skipPrettier) { - if ($line -match "\s*") { - $skipPrettier = $false + if ($skippingComment) { + if ($line -match "") { + $skippingComment = $false continue } if ($line -match "^> ") { @@ -79,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 "" -and -not $skippingComment) + { + $skippingComment = $true + continue + } + if ($skippingComment) { + + if ($line -match "") { + $skippingComment = $false + continue + } + if ($line -match "^> ") { + continue + } + throw "Prettier comment format - expected , but found: '$line'" + } + # End of prettier comment + + # Next, we expect a header if (-not $line.StartsWith("#")) {