Skip to content

Commit 269a4a9

Browse files
justin808claude
andcommitted
Eliminate redundant changelog reads and add dry-run changelog status
- Pass pre-extracted changelog_section to sync_github_release_after_publish to avoid reading CHANGELOG.md twice with the same arguments. - Move changelog availability check outside `unless dry_run` so it runs for both paths, giving the dry-run summary a self-contained pre-flight check. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 09bbd92 commit 269a4a9

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

rakelib/release.rake

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,11 @@ def warn_changelog_missing(gem_root:, npm_version:)
284284
puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
285285
end
286286

287-
def sync_github_release_after_publish(gem_root:, gem_version:, dry_run:)
287+
def sync_github_release_after_publish(gem_root:, gem_version:, dry_run:, changelog_section: nil)
288288
npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(gem_version)
289-
changelog_path = File.join(gem_root, "CHANGELOG.md")
290-
section = extract_changelog_section(changelog_path: changelog_path, npm_version: npm_version)
289+
section = changelog_section || extract_changelog_section(
290+
changelog_path: File.join(gem_root, "CHANGELOG.md"), npm_version: npm_version
291+
)
291292

292293
unless section
293294
puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
@@ -470,6 +471,11 @@ def print_release_summary(release_result)
470471
puts "\nFiles that would be updated:"
471472
staged_files.each { |file| puts " - #{file}" }
472473
puts " - package.json (updated by release-it)"
474+
if changelog_section_found
475+
puts "\nChangelog: ✓ CHANGELOG.md section found for v#{released_npm_version}"
476+
else
477+
puts "\nChangelog: ⚠ No CHANGELOG.md section for v#{released_npm_version} — add one before releasing."
478+
end
473479
puts "\nTo actually release, run: rake \"release[#{released_gem_version}]\""
474480
return
475481
end
@@ -591,13 +597,17 @@ def perform_release(
591597

592598
end
593599

594-
unless dry_run
595-
sync_gem_version = released_gem_version || gem_version.to_s.strip
596-
if sync_gem_version && !sync_gem_version.empty?
597-
released_npm_version ||= Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(sync_gem_version)
598-
changelog_path = File.join(gem_root, "CHANGELOG.md")
599-
changelog_section_found = !extract_changelog_section(changelog_path: changelog_path, npm_version: released_npm_version).nil?
600-
sync_github_release_after_publish(gem_root: gem_root, gem_version: sync_gem_version, dry_run: dry_run)
600+
# Check changelog availability for the summary (both dry-run and live paths).
601+
sync_gem_version = released_gem_version || gem_version.to_s.strip
602+
if sync_gem_version && !sync_gem_version.empty?
603+
released_npm_version ||= Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(sync_gem_version)
604+
changelog_path = File.join(gem_root, "CHANGELOG.md")
605+
changelog_section = extract_changelog_section(changelog_path: changelog_path, npm_version: released_npm_version)
606+
changelog_section_found = !changelog_section.nil?
607+
608+
unless dry_run
609+
sync_github_release_after_publish(gem_root: gem_root, gem_version: sync_gem_version, dry_run: dry_run,
610+
changelog_section: changelog_section)
601611
end
602612
end
603613

0 commit comments

Comments
 (0)