Skip to content

Commit 2885214

Browse files
hsbtclaude
andcommitted
Read current gem versions from repo state instead of NEWS.md
The "to" side of the diff used to come from parsing NEWS.md, which made this script depend on update-NEWS-gemlist.rb having already written the right versions there. Read the authoritative sources directly: scan {ext,lib}/**/*.gemspec for default gems (mirroring the logic in default_gems_list.yml), pick up the RubyGems version from lib/rubygems.rb, and load gems/bundled_gems for the bundled set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fbe968e commit 2885214

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

tool/update-NEWS-github-release.rb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,44 @@ def read_local_news_md
118118
File.read(news_path)
119119
end
120120

121+
# Build a gem=>version map from the current repository state. Default gems
122+
# come from {ext,lib}/**/*.gemspec (mirroring default_gems_list.yml) and
123+
# bundled gems come from gems/bundled_gems. This avoids reading NEWS.md as
124+
# the source of "current versions", which would create a circular dependency
125+
# with update-NEWS-gemlist.rb.
126+
def load_current_versions
127+
require "rubygems"
128+
root = File.expand_path("..", __dir__)
129+
map = {}
130+
131+
rg_path = File.join(root, "lib", "rubygems.rb")
132+
if File.exist?(rg_path)
133+
File.foreach(rg_path) do |line|
134+
if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line
135+
map["RubyGems"] = $1
136+
break
137+
end
138+
end
139+
end
140+
141+
Dir.glob(File.join(root, "{ext,lib}/**/*.gemspec")).each do |path|
142+
spec = Gem::Specification.load(path)
143+
next unless spec
144+
map[spec.name] = spec.version.to_s
145+
end
146+
147+
bundled_path = File.join(root, "gems", "bundled_gems")
148+
if File.exist?(bundled_path)
149+
File.foreach(bundled_path) do |line|
150+
next if line.start_with?("#")
151+
name, version = line.split(" ", 3)
152+
map[name] = version if name && version
153+
end
154+
end
155+
156+
map
157+
end
158+
121159
def parse_stdlib_versions_from_news(body)
122160
# Extract the Stdlib updates section
123161
start_idx = body.index(/^## Stdlib updates$/)
@@ -331,7 +369,7 @@ def update_news_md(results)
331369
update_mode = ARGV.delete("--update")
332370

333371
versions_from = load_versions(ARGV[0])
334-
versions_to = load_versions("news")
372+
versions_to = load_current_versions
335373

336374
results = collect_gem_updates(versions_from, versions_to)
337375

0 commit comments

Comments
 (0)