Skip to content

Commit 1456273

Browse files
authored
fix: get-changelog support for cross-repo links (#82)
* fix: get-changelog support for cross-repo links * chore: changelog
1 parent 80fe8ed commit 1456273

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Don't update from a manually-updated prerelease to a latest stable release that is earlier than the prerelease ([#78](https://github.com/getsentry/github-workflows/pull/78))
8+
- Cross-repo links in changelog notes ([#82](https://github.com/getsentry/github-workflows/pull/82))
89

910
## 2.11.0
1011

updater/scripts/get-changelog.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ try
2121
git clone --depth 1 $RepoUrl $tmpDir
2222

2323
$file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
24-
if ("$file" -eq "")
24+
if ("$file" -eq '')
2525
{
2626
Write-Warning "Couldn't find a changelog"
2727
return
@@ -41,7 +41,7 @@ finally
4141
}
4242

4343
$foundFirst = $false
44-
$changelog = ""
44+
$changelog = ''
4545
for ($i = 0; $i -lt $lines.Count; $i++)
4646
{
4747
$line = $lines[$i]
@@ -70,11 +70,11 @@ if ($changelog.Length -gt 1)
7070
{
7171
$changelog = "# Changelog`n$changelog"
7272
# Increase header level by one.
73-
$changelog = $changelog -replace "(#+) ", '$1# '
73+
$changelog = $changelog -replace '(^|\n)(#+) ', '$1$2# '
7474
# Remove at-mentions.
7575
$changelog = $changelog -replace '@', ''
7676
# Make PR/issue references into links to the original repository (unless they already are links).
77-
$changelog = $changelog -replace '(?<!\[)#([0-9]+)', ('[#$1](' + $RepoUrl + '/issues/$1)')
77+
$changelog = $changelog -replace '(?<!\[)#([0-9]+)(?![\]0-9])', ('[#$1](' + $RepoUrl + '/issues/$1)')
7878
# Replace any links pointing to github.com so that the target PRs/Issues don't get na notification.
7979
$changelog = $changelog -replace ('\(' + $prefix), '(https://github-redirect.dependabot.com/'
8080
}

updater/tests/get-changelog.Tests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,22 @@ Features, fixes and improvements in this release have been contributed by:
103103
throw "Expected changelog to contain message '$msg'"
104104
}
105105
}
106+
107+
It 'supports cross-repo links' {
108+
$actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" `
109+
-RepoUrl 'https://github.com/getsentry/sentry-native' -OldTag '0.7.17' -NewTag '0.7.18'
110+
$expected = @'
111+
## Changelog
112+
### 0.7.18
113+
114+
**Features**:
115+
116+
- Add support for Xbox Series X/S. ([#1100](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1100))
117+
- Add option to set debug log level. ([#1107](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1107))
118+
- Add `traces_sampler` ([#1108](https://github-redirect.dependabot.com/getsentry/sentry-native/pull/1108))
119+
- 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))
120+
'@
121+
122+
$actual | Should -Be $expected
123+
}
106124
}

0 commit comments

Comments
 (0)