diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96c1610..a54312c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,10 @@ To update your existing Danger workflows:
- Updater - Prevent script injection vulnerabilities through workflow inputs ([#98](https://github.com/getsentry/github-workflows/pull/98))
+### Fixes
+
+- Improve changelog generation for non-tagged commits and edge cases ([#115](https://github.com/getsentry/github-workflows/pull/115))
+
## 2.14.1
### Fixes
diff --git a/updater/scripts/get-changelog.ps1 b/updater/scripts/get-changelog.ps1
index 90d5d72..3f34a47 100644
--- a/updater/scripts/get-changelog.ps1
+++ b/updater/scripts/get-changelog.ps1
@@ -5,122 +5,154 @@ param(
)
Set-StrictMode -Version latest
+$PSNativeCommandErrorActionPreference = $true
+$ErrorActionPreference = 'Stop'
$prefix = 'https?://(www\.)?github.com/'
-if (-not ($RepoUrl -match "^$prefix"))
-{
- Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl"
+if (-not ($RepoUrl -match "^$prefix([^/]+)/([^/]+?)(?:\.git)?/?$")) {
+ Write-Warning "Only https://github.com repositories are currently supported. Could not parse repository from URL: $RepoUrl"
return
}
+$repoOwner = $matches[2]
+$repoName = $matches[3]
+$apiRepo = "$repoOwner/$repoName"
+
+# Create temporary directory for changelog files
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
New-Item -ItemType Directory $tmpDir | Out-Null
-try
-{
- git clone --depth 1 $RepoUrl $tmpDir
+# Function to try different changelog filenames
+function Get-ChangelogContent {
+ param($ref, $filePath)
+
+ $changelogNames = @('CHANGELOG.md', 'changelog.md', 'CHANGELOG.txt', 'changelog.txt', 'CHANGELOG')
+
+ foreach ($name in $changelogNames) {
+ try {
+ # Try fetching directly from raw.githubusercontent.com
+ $rawUrl = "https://raw.githubusercontent.com/$apiRepo/$ref/$name"
+ $content = Invoke-RestMethod -Uri $rawUrl -Method Get -ErrorAction SilentlyContinue
+ if ($content) {
+ Set-Content -Path $filePath -Value $content -Encoding UTF8
+ Write-Host "Found $name for ref $ref"
+ return $true
+ }
+ } catch {
+ # Continue to next filename
+ }
+ }
+ return $false
+}
+
+try {
+ Write-Host 'Fetching CHANGELOG files for comparison...'
- $file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
- if ("$file" -eq '')
- {
- Write-Warning "Couldn't find a changelog"
+ # Fetch old changelog
+ $oldChangelogPath = Join-Path $tmpDir 'old-changelog.md'
+ if (-not (Get-ChangelogContent $OldTag $oldChangelogPath)) {
+ Write-Warning "Could not find changelog at $OldTag"
return
}
- elseif ($file -is [Array])
- {
- Write-Warning "Multiple changelogs found: $file"
+
+ # Fetch new changelog
+ $newChangelogPath = Join-Path $tmpDir 'new-changelog.md'
+ if (-not (Get-ChangelogContent $NewTag $newChangelogPath)) {
+ Write-Warning "Could not find changelog at $NewTag"
return
}
- Write-Host "Found changelog: $file"
- [string[]]$lines = Get-Content $file
-}
-finally
-{
- Write-Host "Removing $tmpDir"
- Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir
-}
-$startIndex = -1
-$endIndex = -1
-$changelog = ''
-for ($i = 0; $i -lt $lines.Count; $i++)
-{
- $line = $lines[$i]
-
- if ($startIndex -lt 0)
- {
- if ($line -match "^#+ +v?$NewTag\b")
- {
- $startIndex = $i
+ Write-Host "Generating changelog diff between $OldTag and $NewTag..."
+
+ # Generate diff using git diff --no-index
+ # git diff returns exit code 1 when differences are found, which is expected behavior
+ # We need to handle this properly when PSNativeCommandErrorActionPreference is enabled
+ $fullDiff = & {
+ $oldErrorActionPreference = $ErrorActionPreference
+ $ErrorActionPreference = 'Continue'
+ try {
+ git diff --no-index $oldChangelogPath $newChangelogPath
+ } finally {
+ $ErrorActionPreference = $oldErrorActionPreference
}
}
- elseif ($line -match "^#+ +v?$OldTag\b")
- {
- $endIndex = $i - 1
- break
+
+ # The first lines are diff metadata, skip them
+ $fullDiff = $fullDiff -split "`n" | Select-Object -Skip 4
+ if ([string]::IsNullOrEmpty("$fullDiff")) {
+ Write-Host "No differences found between $OldTag and $NewTag"
+ return
+ } else {
+ Write-Host "Successfully created a changelog diff - $($fullDiff.Count) lines"
}
-}
-# If the changelog doesn't have a section for the oldTag, stop at the first SemVer that's lower than oldTag.
-if ($endIndex -lt 0)
-{
- $endIndex = $lines.Count - 1 # fallback, may be overwritten below
- try
- {
- $semverOldTag = [System.Management.Automation.SemanticVersion]::Parse($OldTag)
- for ($i = $startIndex; $i -lt $lines.Count; $i++)
- {
- $line = $lines[$i]
- if ($line -match '^#+ +v?([0-9]+.*)$')
- {
- try
- {
- if ($semverOldTag -ge [System.Management.Automation.SemanticVersion]::Parse($matches[1]))
- {
- $endIndex = $i - 1
+ # Extract only the added lines (lines starting with + but not ++)
+ $addedLines = $fullDiff | Where-Object { $_ -match '^[+][^+]*' } | ForEach-Object { $_.Substring(1) }
+
+ if ($addedLines.Count -gt 0) {
+ # Create clean changelog from added lines
+ $changelog = ($addedLines -join "`n").Trim()
+
+ # Apply formatting to clean changelog
+ if ($changelog.Length -gt 0) {
+ # Add header
+ if (-not ($changelog -match '^(##|#) Changelog')) {
+ $changelog = "## Changelog`n`n$changelog"
+ }
+
+ # Increase header level by one for content (not the main header)
+ $changelog = $changelog -replace '(^|\n)(#+) ', '$1$2# ' -replace '^### Changelog', '## Changelog'
+
+ # Only add details section if there are deletions or modifications (not just additions)
+ $hasModifications = $fullDiff | Where-Object { $_ -match '^[-]' -and $_ -notmatch '^[-]{3}' }
+ if ($hasModifications) {
+ $changelog += "`n`n`nFull CHANGELOG.md diff
`n`n"
+ $changelog += '```diff' + "`n"
+ $changelog += $fullDiff -join "`n"
+ $changelog += "`n" + '```' + "`n`n "
+ }
+
+ # Apply standard formatting
+ # Remove at-mentions.
+ $changelog = $changelog -replace '@', ''
+ # Make PR/issue references into links to the original repository (unless they already are links).
+ $changelog = $changelog -replace '(? :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
}
+
+ Write-Host "Final changelog length: $($changelog.Length) characters"
+ Write-Output $changelog
}
}
- catch {}
-}
-
-# Slice changelog lines from startIndex to endIndex.
-if ($startIndex -ge 0)
-{
- $changelog = ($lines[$startIndex..$endIndex] -join "`n").Trim()
-}
-else
-{
- $changelog = ''
-}
-if ($changelog.Length -gt 1)
-{
- $changelog = "# Changelog`n$changelog"
- # Increase header level by one.
- $changelog = $changelog -replace '(^|\n)(#+) ', '$1$2# '
- # Remove at-mentions.
- $changelog = $changelog -replace '@', ''
- # Make PR/issue references into links to the original repository (unless they already are links).
- $changelog = $changelog -replace '(? :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
}
-$changelog
+# This resets the $LASTEXITCODE set by git diff above.
+# Note that this only runs in the successful path.
+exit 0
diff --git a/updater/tests/get-changelog.Tests.ps1 b/updater/tests/get-changelog.Tests.ps1
index 0a09e0d..0c7c4c8 100644
--- a/updater/tests/get-changelog.Tests.ps1
+++ b/updater/tests/get-changelog.Tests.ps1
@@ -2,31 +2,15 @@
Describe 'get-changelog' {
It 'with existing versions' {
$actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
- -RepoUrl 'https://github.com/getsentry/github-workflows' -OldTag '1.0.0' -NewTag '2.1.0'
+ -RepoUrl 'https://github.com/getsentry/github-workflows' -OldTag 'v2.0.0' -NewTag 'v2.1.0'
$expected = @'
## Changelog
+
### 2.1.0
#### Features
- New reusable workflow, `danger.yml`, to check Pull Requests with predefined rules ([#34](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/34))
-
-### 2.0.0
-
-#### Changes
-
-- Rename `api_token` secret to `api-token` ([#21](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/21))
-- Change changelog target section header from "Features" to "Dependencies" ([#19](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/19))
-
-#### Features
-
-- Add `pr-strategy` switch to choose between creating new PRs or updating an existing one ([#22](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/22))
-- Add `changelog-section` input setting to specify target changelog section header ([#19](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/19))
-
-#### Fixes
-
-- Preserve changelog bullet-point format ([#20](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/20))
-- Changelog section parsing when an entry text contains the section name in the text ([#25](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/25))
'@
$actual | Should -Be $expected
@@ -57,6 +41,7 @@ Describe 'get-changelog' {
-RepoUrl 'https://github.com/getsentry/sentry-cli' -OldTag '2.1.0' -NewTag '2.2.0'
$expected = @'
## Changelog
+
### 2.2.0
#### Various fixes & improvements
@@ -73,6 +58,7 @@ Describe 'get-changelog' {
-RepoUrl 'https://github.com/getsentry/sentry-native' -OldTag '0.4.16' -NewTag '0.4.17'
$expected = @'
## Changelog
+
### 0.4.17
**Fixes**:
@@ -91,15 +77,17 @@ Features, fixes and improvements in this release have been contributed by:
It 'Does not show versions older than OldTag even if OldTag is missing' {
$actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
- -RepoUrl 'https://github.com/getsentry/github-workflows' -OldTag '2.1.5' -NewTag '2.2.1'
+ -RepoUrl 'https://github.com/getsentry/github-workflows' -OldTag 'v2.1.1' -NewTag 'v2.2.1'
$actual | Should -Be @'
## Changelog
+
### 2.2.1
#### Fixes
- Support comments when parsing pinned actions in Danger ([#40](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/40))
+
### 2.2.0
#### Features
@@ -110,7 +98,7 @@ Features, fixes and improvements in this release have been contributed by:
It 'truncates too long text' {
$actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
- -RepoUrl 'https://github.com/getsentry/sentry-cli' -OldTag '1.0.0' -NewTag '2.4.0'
+ -RepoUrl 'https://github.com/getsentry/sentry-cli' -OldTag '1.60.0' -NewTag '2.32.0'
if ($actual.Length -gt 61000)
{
throw "Expected the content to be truncated to less-than 61k characters, but got: $($actual.Length)"
@@ -128,16 +116,146 @@ Features, fixes and improvements in this release have been contributed by:
-RepoUrl 'https://github.com/getsentry/sentry-native' -OldTag '0.7.17' -NewTag '0.7.18'
$expected = @'
## Changelog
+
### 0.7.18
**Features**:
- Add support for Xbox Series X/S. ([#1100](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1100))
- Add option to set debug log level. ([#1107](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1107))
-- Add `traces_sampler`. ([#1108](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1108))
+- Add `traces_sampler` ([#1108](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1108))
- Provide support for C++17 compilers when using the `crashpad` backend. ([#1110](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1110), [crashpad#116](https://github-redirect.dependabot.com/getsentry/crashpad/pull/116), [mini_chromium#1](https://github-redirect.dependabot.com/getsentry/mini_chromium/pull/1))
'@
$actual | Should -Be $expected
}
+
+ It 'handles commit SHA as OldTag by resolving to tag' {
+ # Test with a SHA that corresponds to a known tag (0.9.1)
+ # This should resolve the SHA to the tag and use normal changelog logic
+ $actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
+ -RepoUrl 'https://github.com/getsentry/sentry-native' `
+ -OldTag 'a64d5bd8ee130f2cda196b6fa7d9b65bfa6d32e2' `
+ -NewTag '0.11.0'
+
+ $expected = @'
+## Changelog
+
+### 0.11.0
+
+**Breaking changes**:
+
+- Add `user_data` parameter to `traces_sampler`. ([#1346](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1346))
+
+**Fixes**:
+
+- Include `stddef.h` explicitly in `crashpad` since future `libc++` revisions will stop providing this include transitively. ([#1375](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1375), [crashpad#132](https://github-redirect.dependabot.com/getsentry/crashpad/pull/132))
+- Fall back on `JWASM` in the _MinGW_ `crashpad` build only if _no_ `CMAKE_ASM_MASM_COMPILER` has been defined. ([#1375](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1375), [crashpad#133](https://github-redirect.dependabot.com/getsentry/crashpad/pull/133))
+- Prevent `crashpad` from leaking Objective-C ARC compile options into any parent target linkage. ([#1375](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1375), [crashpad#134](https://github-redirect.dependabot.com/getsentry/crashpad/pull/134))
+- Fixed a TOCTOU race between session init/shutdown and event capture. ([#1377](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1377))
+- Make the Windows resource generation aware of config-specific output paths for multi-config generators. ([#1383](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1383))
+- Remove the `ASM` language from the top-level CMake project, as this triggered CMake policy `CMP194` which isn't applicable to the top-level. ([#1384](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1384))
+
+**Features**:
+
+- Add a configuration to disable logging after a crash has been detected - `sentry_options_set_logger_enabled_when_crashed()`. ([#1371](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1371))
+
+**Internal**:
+
+- Support downstream Xbox SDK specifying networking initialization mechanism. ([#1359](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1359))
+- Added `crashpad` support infrastructure for the external crash reporter feature. ([#1375](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1375), [crashpad#131](https://github-redirect.dependabot.com/getsentry/crashpad/pull/131))
+
+**Docs**:
+
+- Document the CMake 4 requirement on macOS `SDKROOT` due to its empty default for `CMAKE_OSX_SYSROOT` in the `README`. ([#1368](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1368))
+
+**Thank you**:
+
+- [JanFellner](https://github-redirect.dependabot.com/JanFellner)
+
+### 0.10.1
+
+**Internal**:
+
+- Correctly apply dynamic mutex initialization in unit-tests (fixes running unit-tests in downstream console SDKs). ([#1337](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1337))
+
+### 0.10.0
+
+**Breaking changes**:
+
+- By using transactions as automatic trace boundaries, transactions will, by default, no longer be part of the same singular trace. This is not the case when setting trace boundaries explicitly (`sentry_regenerate_trace()` or `sentry_set_trace()`), which turns off the automatic management of trace boundaries. ([#1270](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1270))
+- Change transaction sampling to be trace-based. This does not affect you when transactions are used for automatic trace boundaries (as described above), since every transaction is part of a new trace. However, if you manage trace boundaries manually (using `sentry_regenerate_trace()`) or run the Native SDK inside a downstream SDK like the Unity SDK, where these SDKs will manage the trace boundaries, for a given `traces_sample_rate`, either all transactions in a trace get sampled or none do with probability equal to that sample rate. ([#1254](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1254))
+- Moved Xbox toolchains to an Xbox-specific repository [sentry-xbox](https://github-redirect.dependabot.com/getsentry/sentry-xbox). You can request access to the repository by following the instructions in [Xbox documentation](https://docs.sentry.io/platforms/xbox/). ([#1329](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1329))
+
+**Features**:
+
+- Add `sentry_clear_attachments()` to allow clearing all previously added attachments in the global scope. ([#1290](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1290))
+- Automatically set trace boundaries with every transaction. ([#1270](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1270))
+- Provide `sentry_regenerate_trace()` to allow users to set manual trace boundaries. ([#1293](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1293))
+- Add `Dynamic Sampling Context (DSC)` to events. ([#1254](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1254))
+- Add `sentry_value_new_feedback` and `sentry_capture_feedback` to allow capturing [User Feedback](https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback). ([#1304](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1304))
+ - Deprecate `sentry_value_new_user_feedback` and `sentry_capture_user_feedback` in favor of the new API.
+- Add `sentry_envelope_read_from_file`, `sentry_envelope_get_header`, and `sentry_capture_envelope`. ([#1320](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1320))
+- Add `(u)int64` `sentry_value_t` type. ([#1326](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1326))
+
+**Meta**:
+
+- Marked deprecated functions with `SENTRY_DEPRECATED(msg)`. ([#1308](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1308))
+
+**Internal**:
+
+- Crash events from Crashpad now have `event_id` defined similarly to other backends. This makes it possible to associate feedback at the time of crash. ([#1319](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1319))
+'@
+
+ $actual | Should -Be $expected
+ }
+
+ It 'handles commit SHA as OldTag by getting changelog diff when SHA does not map to tag' {
+ # Test with a SHA that doesn't correspond to any tag - should use diff approach
+ # This SHA is between v2.8.0 and v2.8.1 in github-workflows repo
+ $actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
+ -RepoUrl 'https://github.com/getsentry/github-workflows' `
+ -OldTag 'cc24e8eb3c13d3d2e949f4a20c86d2ccac310c11' `
+ -NewTag 'v2.8.1'
+
+ $expected = @'
+## Changelog
+
+### 2.8.1
+#### Fixes
+- Sentry-CLI integration test - set server script root so assets access works. ([#63](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/63))
+
+
+Full CHANGELOG.md diff
+
+```diff
+ -1,12 +1,10
+ # Changelog
+
+-## Unreleased
++## 2.8.1
+
+-### Dependencies
++### Fixes
+
+-- Bump CLI from v2.0.0 to v2.0.4 ([#60](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/60))
+- - [changelog](https://github-redirect.dependabot.com/getsentry/sentry-cli/blob/master/CHANGELOG.md[#204](https://github-redirect.dependabot.com/getsentry/github-workflows/issues/204))
+- - [diff](https://github-redirect.dependabot.com/getsentry/sentry-cli/compare/2.0.0...2.0.4)
++- Sentry-CLI integration test - set server script root so assets access works. ([#63](https://github-redirect.dependabot.com/getsentry/github-workflows/pull/63))
+
+ ## 2.8.0
+
+```
+
+
+'@
+
+ # there's an issue with line endings so we'll compare line by line
+ $actualLines = $actual -split "`n"
+ $expectedLines = $expected -split "`n"
+ $actualLines.Count | Should -Be $expectedLines.Count
+ for ($i = 0; $i -lt $actualLines.Count; $i++) {
+ $actualLines[$i].Trim() | Should -Be $expectedLines[$i].Trim()
+ }
+ }
}