Skip to content
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
20 changes: 12 additions & 8 deletions scripts/update-changelog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ for ($i = 0; $i -lt $lines.Count; $i++)
break
}

# Make sure that there's a the requested section header
# Make sure that there's the requested section header
:outer for ($i = 0; $i -lt $lines.Count; $i++)
{
$line = $lines[$i]
Expand Down Expand Up @@ -115,9 +115,9 @@ $PullRequestMD = "[#$($PR | Split-Path -Leaf)]($PR)"
$updated = $false
for ($i = 0; $i -lt $sectionEnd; $i++)
{
if (($lines[$i] -match "^- Bump $Name.*to") -and `
($lines[$i + 1] -match "^ - \[changelog\]\($RepoUrl") -and `
($lines[$i + 2] -match "^ - \[diff\]\($RepoUrl"))
if (($lines[$i] -match "^[-*] Bump $Name.*to") -and `
($lines[$i + 1] -match "^ [-*] \[changelog\]\($RepoUrl") -and `
($lines[$i + 2] -match "^ [-*] \[diff\]\($RepoUrl"))
{
Write-Host "Found an existing changelog entry at $($i):"
Write-Host " ", $lines[$i]
Expand All @@ -126,7 +126,7 @@ for ($i = 0; $i -lt $sectionEnd; $i++)

$lines[$i] = $lines[$i] -replace "(Bump $Name.*)to .* \(", "`$1to $newTagNice ("
$lines[$i] = $lines[$i] -replace "\)$", ", $PullRequestMD)"
$lines[$i + 1] = " - [changelog]($RepoUrl/blob/$MainBranch/CHANGELOG.md#$tagAnchor)"
$lines[$i + 1] = $lines[$i + 1] -replace "#.*\)", "#$tagAnchor)"
$lines[$i + 2] = $lines[$i + 2] -replace "\.\.\..*\)$", "...$NewTag)"

Write-Host "Updating the entry to: "
Expand All @@ -140,9 +140,13 @@ for ($i = 0; $i -lt $sectionEnd; $i++)

if (!$updated)
{
$entry = @("- Bump $Name from $oldTagNice to $newTagNice ($PullRequestMD)",
" - [changelog]($RepoUrl/blob/$MainBranch/CHANGELOG.md#$tagAnchor)",
" - [diff]($RepoUrl/compare/$OldTag...$NewTag)")
# Find what character is used as a bullet-point separator - look for the first bullet-point object that wasn't created by this script.
$bulletPoint = $lines | Where-Object { ($_ -match "^ *[-*] ") -and -not ($_ -match "(Bump .* to|\[changelog\]|\[diff\])") } | Select-Object -First 1
$bulletPoint = "$bulletPoint-"[0]

$entry = @("$bulletPoint Bump $Name from $oldTagNice to $newTagNice ($PullRequestMD)",
" $bulletPoint [changelog]($RepoUrl/blob/$MainBranch/CHANGELOG.md#$tagAnchor)",
" $bulletPoint [diff]($RepoUrl/compare/$OldTag...$NewTag)")

Write-Host "Adding a changelog entry at line $($sectionEnd):"
foreach ($line in $entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

- 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))
- Bump Dependency from v7.16.0 to v7.17.0 ([#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/7.16.0...7.17.0)
* Bump Dependency from v7.16.0 to v7.17.0 ([#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/7.16.0...7.17.0)

### Notes

Expand Down
5 changes: 3 additions & 2 deletions tests/testdata/changelog/update/CHANGELOG.md.expected
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

### Dependencies

- 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)
- 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
Expand Down
5 changes: 3 additions & 2 deletions tests/testdata/changelog/update/CHANGELOG.md.original
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

### Dependencies

- 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)
- 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
Expand Down