Skip to content

Commit 834a088

Browse files
vaindclaude
andcommitted
refactor: move changelog fetching into Get-ChangelogFromDiff function
Cleaned up the main logic by encapsulating changelog file fetching within the Get-ChangelogFromDiff function itself. Changes: - Get-ChangelogFromDiff now takes (oldTag, newTag, tmpDir) instead of file paths - Function handles its own changelog file fetching and returns null if files don't exist - Main logic is simplified to just call both functions and use whichever succeeds - Removes duplicate code and makes the interface cleaner - All 16 tests continue to pass Benefits: - Cleaner separation of concerns - Simpler main logic flow - Each function is more self-contained - Easier to understand and maintain 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c55aed2 commit 834a088

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

updater/scripts/get-changelog.ps1

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,19 @@ function Get-ChangelogFromCommits {
139139

140140
# Function to generate changelog from diff between changelog files
141141
function Get-ChangelogFromDiff {
142-
param($oldChangelogPath, $newChangelogPath, $oldTag, $newTag)
142+
param($oldTag, $newTag, $tmpDir)
143+
144+
# Try to fetch changelog files for both tags
145+
$oldChangelogPath = Join-Path $tmpDir 'old-changelog.md'
146+
$hasOldChangelog = Get-ChangelogContent $oldTag $oldChangelogPath
147+
148+
$newChangelogPath = Join-Path $tmpDir 'new-changelog.md'
149+
$hasNewChangelog = Get-ChangelogContent $newTag $newChangelogPath
150+
151+
# Return null if we don't have both changelog files
152+
if (-not $hasOldChangelog -or -not $hasNewChangelog) {
153+
return $null
154+
}
143155

144156
Write-Host "Generating changelog diff between $oldTag and $newTag..."
145157

@@ -233,20 +245,10 @@ function Format-ChangelogContent {
233245
try {
234246
Write-Host 'Fetching CHANGELOG files for comparison...'
235247

236-
# Fetch old changelog
237-
$oldChangelogPath = Join-Path $tmpDir 'old-changelog.md'
238-
$hasOldChangelog = Get-ChangelogContent $OldTag $oldChangelogPath
239-
240-
# Fetch new changelog
241-
$newChangelogPath = Join-Path $tmpDir 'new-changelog.md'
242-
$hasNewChangelog = Get-ChangelogContent $NewTag $newChangelogPath
243-
244248
$changelog = $null
245249

246250
# Try changelog file diff first, fall back to git commits if not available
247-
if ($hasOldChangelog -and $hasNewChangelog) {
248-
$changelog = Get-ChangelogFromDiff $oldChangelogPath $newChangelogPath $OldTag $NewTag
249-
}
251+
$changelog = Get-ChangelogFromDiff $OldTag $NewTag $tmpDir
250252

251253
# Fall back to git commits if no changelog files or no diff found
252254
if (-not $changelog) {

0 commit comments

Comments
 (0)