Skip to content

Commit 8887272

Browse files
vaindclaude
andcommitted
fix: address valid review comments for robustness
- Fix diff checking logic: use string conversion for proper emptiness check - Fix truncation safety: handle case when no newlines exist in content - Add graceful fallback to direct truncation when LastIndexOf returns -1 - All tests continue to pass (11/11 tests passing) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8bdccee commit 8887272

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

updater/scripts/get-changelog.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ try {
7979

8080
# The first lines are diff metadata, skip them
8181
$fullDiff = $fullDiff -split "`n" | Select-Object -Skip 4
82-
if ([string]::IsNullOrEmpty($fullDiff)) {
82+
if ([string]::IsNullOrEmpty("$fullDiff")) {
8383
Write-Host "No differences found between $OldTag and $NewTag"
8484
return
8585
} else {
@@ -126,7 +126,13 @@ try {
126126
$oldLength = $changelog.Length
127127
Write-Warning "Truncating changelog because it's $($changelog.Length - $limit) characters longer than the limit $limit."
128128
while ($changelog.Length -gt $limit) {
129-
$changelog = $changelog.Substring(0, $changelog.LastIndexOf("`n"))
129+
$lastNewlineIndex = $changelog.LastIndexOf("`n")
130+
if ($lastNewlineIndex -eq -1) {
131+
# No newlines found, just truncate to limit
132+
$changelog = $changelog.Substring(0, $limit)
133+
break
134+
}
135+
$changelog = $changelog.Substring(0, $lastNewlineIndex)
130136
}
131137
$changelog += "`n`n> :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
132138
}

0 commit comments

Comments
 (0)