summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2025-12-11 14:41:36 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2025-12-11 14:49:17 -0800
commita973526c050fec044ffd7ceeba0ac8e8a1fed299 (patch)
treebb0f871a115a4284c8c225eff4c9496fceb3c019 /tool
parent0564214a00450371527c7bd69fc13618e5f25f30 (diff)
tool/format-release: Fix the tag format for Ruby 4.0+
Diffstat (limited to 'tool')
-rwxr-xr-xtool/format-release18
1 files changed, 13 insertions, 5 deletions
diff --git a/tool/format-release b/tool/format-release
index b7ad74a095..b38263f9f4 100755
--- a/tool/format-release
+++ b/tool/format-release
@@ -62,19 +62,18 @@ eom
if z != 0
prev_tag = nil
elsif y != 0
- prev_tag = "v#{x}_#{y-1}_0"
prev_ver = "#{x}.#{y-1}.0"
+ prev_tag = version_tag(prev_ver)
else # y == 0 && z == 0
case x
when 3
- prev_tag = "v2_7_0"
prev_ver = "2.7.0"
when 4
- prev_tag = "v3_4_0"
prev_ver = "3.4.0"
else
raise "it doesn't know what is the previous version of '#{version}'"
end
+ prev_tag = version_tag(prev_ver)
end
uri = "https://cache.ruby-lang.org/pub/tmp/ruby-info-#{version}-draft.yml"
@@ -95,7 +94,7 @@ eom
if prev_tag
# show diff shortstat
- tag = "v#{version.gsub(/[.\-]/, '_')}"
+ tag = version_tag(version)
stat = `git -C #{rubydir} diff -l0 --shortstat #{prev_tag}..#{tag}`
files_changed, insertions, deletions = stat.scan(/\d+/)
end
@@ -189,7 +188,7 @@ eom
if /\.0(?:-\w+)?\z/ =~ ver
# preview, rc, or first release
entry <<= <<eom
- tag: v#{ver.tr('.-', '_')}
+ tag: #{version_tag(ver)}
stats:
files_changed: #{files_changed}
insertions: #{insertions}
@@ -248,6 +247,15 @@ eom
puts line
end
end
+
+ def self.version_tag(version)
+ major_version = Integer(version.split('.', 2)[0])
+ if major_version >= 4
+ "v#{version}"
+ else
+ "v#{version.tr('.-', '_')}"
+ end
+ end
end
def main