A platform for community discussion. Free, open, simple.
DEV: Bump `latest` branch version on security fixes (#37774)
Loïc Guitaut9d144cac4b71
diff --git a/config/initializers/000-zeitwerk.rb b/config/initializers/000-zeitwerk.rbindex 50470d4126b..a4855a1743b 100644--- a/config/initializers/000-zeitwerk.rb+++ b/config/initializers/000-zeitwerk.rb@@ -53,6 +53,7 @@ Rails.autoloaders.main.ignore("lib/generators","lib/freedom_patches","lib/i18n/backend",+ "lib/release_utils","lib/unicorn_logstash_patch.rb","lib/pitchfork_logstash_patch.rb",)diff --git a/lib/release_utils/version.rb b/lib/release_utils/version.rbnew file mode 100644index 00000000000..2c279e6407e--- /dev/null+++ b/lib/release_utils/version.rb@@ -0,0 +1,93 @@+# frozen_string_literal: true++module ReleaseUtils+ class Version+ include Comparable++ PRE_RELEASE = "latest"++ attr_reader :major, :minor, :patch, :pre, :revision++ protected attr_reader :gem_version++ def initialize(version_string)+ @gem_version = Gem::Version.new(version_string)++ segments = gem_version.segments+ @major = segments[0]+ @minor = segments[1] || 1+ @patch = segments[2] || 0++ @pre, @revision = segments.drop(3).drop_while { it == "pre" } if gem_version.prerelease?++ freeze+ end++ class << self+ def current+ version_string = File.read("lib/version.rb")[/STRING = "(.*)"/, 1]+ raise "Unable to parse current version from lib/version.rb" unless version_string+ new(version_string)+ end++ def next+ target = new("#{Time.current.strftime("%Y.%-m")}.0-#{PRE_RELEASE}")+ return target if target > current+ current.next_development_cycle+ end+ end++ def <=>(other)+ other = self.class.new(other) if other.is_a?(String)+ return unless other.is_a?(self.class)+ gem_version <=> other.gem_version+ end++ def same_development_cycle?(other)+ development? && other.development? && without_revision == other.without_revision+ end++ def same_series?(other)+ series == other.series+ end++ def development?+ pre == PRE_RELEASE+ end++ def series+ "#{major}.#{minor}"+ end++ def branch_name+ "release/#{series}"+ end++ def tag_name+ "v#{self}"+ end++ def without_revision+ return self unless revision+ self.class.new("#{major}.#{minor}.#{patch}-#{pre}")+ end++ def next_development_cycle+ carry, new_minor = minor.divmod(12)+ self.class.new("#{major + carry}.#{new_minor + 1}.0-#{PRE_RELEASE}")+ end++ def next_revision+ raise "next_revision can only be called on development versions" unless development?+ self.class.new("#{major}.#{minor}.#{patch}-#{pre}.#{revision.to_i + 1}")+ end++ def to_s+ "#{major}.#{minor}.#{patch}#{"-#{pre}" if pre}#{".#{revision}" if revision}"+ end++ def inspect+ "#<#{self.class} #{self}>"+ end+ end+enddiff --git a/lib/tasks/release.rake b/lib/tasks/release.rakeindex be9f2b69719..58495a8c08c 100644--- a/lib/tasks/release.rake+++ b/lib/tasks/release.rake@@ -1,6 +1,7 @@# frozen_string_literal: truerequire "tty-prompt"+require_relative "../release_utils/version"module ReleaseUtilsPRIMARY_RELEASE_TAG = "release"@@ -39,13 +40,6 @@ module ReleaseUtilsFile.read("lib/version.rb")end- def self.parse_current_version- version = read_version_rb[/STRING = "(.*)"/, 1]- raise "Unable to parse current version" if version.nil?- puts "Parsed current version: #{version.inspect}"- version- end-def self.write_version(version)File.write("lib/version.rb", read_version_rb.sub(/STRING = ".*"/, "STRING = \"#{version}\""))end@@ -112,9 +106,13 @@ module ReleaseUtilsenddef self.confirm(msg)+ return true if test_mode?+ TTY::Prompt.new.yes?(msg)+ end++ def self.confirm_or_abort(msg)return if test_mode?- prompt = TTY::Prompt.new- raise "Aborted" unless prompt.yes?(msg)+ raise "Aborted" unless confirm(msg)enddef self.merge_pr(base:, branch:)@@ -124,7 +122,7 @@ module ReleaseUtilsendloop do- confirm "Ready to merge #{branch}?"+ confirm_or_abort "Ready to merge #{branch}?"if test_mode?git "push", "origin", "#{branch}:#{base}"@@ -183,43 +181,38 @@ namespace :release dotask "maybe_cut_branch", [:check_ref] do |t, args|check_ref = args[:check_ref]- new_branch_name = nilnew_version = nilprevious_version = nilReleaseUtils.with_clean_worktree("main") doReleaseUtils.git("checkout", check_ref.to_s)- new_version = ReleaseUtils.parse_current_version+ new_version = ReleaseUtils::Version.currentReleaseUtils.git("checkout", "#{check_ref}^1")- previous_version = ReleaseUtils.parse_current_version+ previous_version = ReleaseUtils::Version.currentend- next "version has not changed" if new_version == previous_version+ raise "Unexpected previous version" if !previous_version.development?+ raise "Unexpected new version" if !new_version.development?- raise "Unexpected previous version" if !previous_version.ends_with? "-latest"- raise "Unexpected new version" if !new_version.ends_with? "-latest"- if Gem::Version.new(new_version) < Gem::Version.new(previous_version)- raise "New version is smaller than old version"- end+ next "version has not changed" if new_version.same_development_cycle?(previous_version)- parts = previous_version.split(".")- new_branch_name = "release/#{parts[0]}.#{parts[1]}"+ raise "New version is smaller than old version" if new_version < previous_version- ReleaseUtils.git("branch", new_branch_name, "#{check_ref}^1")- puts "Created new branch #{new_branch_name}"+ ReleaseUtils.git("branch", previous_version.branch_name, "#{check_ref}^1")+ puts "Created new branch #{previous_version.branch_name}"File.write(ENV["GITHUB_OUTPUT"] || "/dev/null",- "new_branch_name=#{new_branch_name}\n",+ "new_branch_name=#{previous_version.branch_name}\n",mode: "a",)if ReleaseUtils.dry_run?- puts "[DRY RUN] Skipping pushing branch #{new_branch_name} to origin"+ puts "[DRY RUN] Skipping pushing branch #{previous_version.branch_name} to origin"else- ReleaseUtils.git("push", "--set-upstream", "origin", new_branch_name)- puts "Pushed branch #{new_branch_name} to origin"+ ReleaseUtils.git("push", "--set-upstream", "origin", previous_version.branch_name)+ puts "Pushed branch #{previous_version.branch_name} to origin"endputs "Done!"@@ -242,21 +235,20 @@ namespace :release donextend- ReleaseUtils.parse_current_version+ ReleaseUtils::Version.currentend+ next unless current_version- tag_name = "v#{current_version}"-- if ReleaseUtils.ref_exists?(tag_name)- puts "Tag #{tag_name} already exists, skipping"+ if ReleaseUtils.ref_exists?(current_version.tag_name)+ puts "Tag #{current_version.tag_name} already exists, skipping"else- puts "Tagging release #{tag_name}"- ReleaseUtils.git "tag", "-a", tag_name, "-m", "version #{current_version}"+ puts "Tagging release #{current_version.tag_name}"+ ReleaseUtils.git "tag", "-a", current_version.tag_name, "-m", "version #{current_version}"if ReleaseUtils.dry_run?puts "[DRY RUN] Skipping pushing tag to origin"else- ReleaseUtils.git "push", "origin", "refs/tags/#{tag_name}"+ ReleaseUtils.git "push", "origin", "refs/tags/#{current_version.tag_name}"endend@@ -270,14 +262,12 @@ namespace :release docurrent_version =ReleaseUtils.with_clean_worktree("main") doReleaseUtils.git "checkout", check_ref.to_s- ReleaseUtils.parse_current_version+ ReleaseUtils::Version.currentend- released_versions = ReleaseUtils.released_versions- current_minor = current_version.split(".").first(2).join(".") + ".0"- current_minor_version = Gem::Version.new(current_minor)+ released_versions = ReleaseUtils.released_versions.map(&ReleaseUtils::Version.method(:new))- if released_versions.empty? || current_minor_version >= released_versions.last+ if released_versions.empty? || current_version >= released_versions.lastReleaseUtils::RELEASE_TAGS.each do |synonym_tag|message =if synonym_tag == ReleaseUtils::PRIMARY_RELEASE_TAG@@ -300,8 +290,8 @@ namespace :release doend# Update ESR tags if this version is in the latest released ESR series- released_esrs = ReleaseUtils.released_esrs- if released_esrs.any? && current_minor_version == released_esrs.last+ released_esrs = ReleaseUtils.released_esrs.map(&ReleaseUtils::Version.method(:new))+ if released_esrs.any? && current_version.same_series?(released_esrs.last)ReleaseUtils::ESR_TAGS.each do |synonym_tag|message =if synonym_tag == ReleaseUtils::PRIMARY_ESR_TAG@@ -333,29 +323,15 @@ namespace :release doReleaseUtils.git "branch", "-D", pr_branch_name if ReleaseUtils.ref_exists?(pr_branch_name)ReleaseUtils.git "checkout", "-b", pr_branch_name- current_version = ReleaseUtils.parse_current_version-- target_version_number = "#{Time.now.strftime("%Y.%-m")}.0-latest"+ current_version = ReleaseUtils::Version.current+ target_version = ReleaseUtils::Version.next- if Gem::Version.new(target_version_number) <= Gem::Version.new(current_version)- puts "Target version #{current_version} is already >= #{target_version_number}. Incrementing instead."- major, minor, patch_and_pre = current_version.split(".")- minor = (minor.to_i + 1).to_s-- if minor.to_i > 12 && Time.now.month == 12- major = (major.to_i + 1).to_s- minor = "1"- end-- target_version_number = "#{major}.#{minor}.#{patch_and_pre}"- end-- ReleaseUtils.write_version(target_version_number)- ReleaseUtils.update_versions_json(target_version_number.split(".").first(2).join("."))+ ReleaseUtils.write_version(target_version)+ ReleaseUtils.update_versions_json(target_version.series)ReleaseUtils.git "add", "lib/version.rb", "versions.json"ReleaseUtils.git "commit","-m",- "DEV: Begin development of v#{target_version_number}\n\nMerging this will trigger the creation of a `release/#{current_version.sub(".0-latest", "")}` branch on the preceding commit."+ "DEV: Begin development of v#{target_version}\n\nMerging this will trigger the creation of a `#{current_version.branch_name}` branch on the preceding commit."endif ReleaseUtils.dry_run?@@ -367,41 +343,6 @@ namespace :release doendend- desc "Prepare version bump"- task "prepare_next_version_branch", [:branch] do |t, args|- branch = args[:branch]-- raise "Expected branch to start with 'release/'" if !branch.starts_with?("release/")-- pr_branch_name = "version-bump/#{args[:branch]}"-- ReleaseUtils.with_clean_worktree(branch) do- ReleaseUtils.git "branch", "-D", pr_branch_name if ReleaseUtils.ref_exists?(pr_branch_name)- ReleaseUtils.git "checkout", "-b", pr_branch_name-- current_version = ReleaseUtils.parse_current_version- target_version_number =- if current_version.end_with?("-latest")- current_version.sub("-latest", "")- else- parts = current_version.split(".")- "#{parts[0]}.#{parts[1]}.#{parts[2].to_i + 1}"- end-- ReleaseUtils.write_version(target_version_number)- ReleaseUtils.git "add", "lib/version.rb"- ReleaseUtils.git "commit",- "-m",- "DEV: Bump version on `#{branch}` to `v#{target_version_number}`"- end-- ReleaseUtils.git "push", "-f", "--set-upstream", "origin", pr_branch_name-- ReleaseUtils.make_pr(base: branch, branch: pr_branch_name)-- puts "Done! Branch #{pr_branch_name} has been pushed to origin and a pull request has been created."- end-desc <<~DESCStage security fixes from private-mirror PRs into a single branch for review/merge.Fetches open PRs from private-mirror and presents an interactive selection.@@ -476,10 +417,20 @@ namespace :release doReleaseUtils.git "cherry-pick", "#{first_commit_on_branch}^..#{ref}"end+ if base == "main" &&+ ReleaseUtils.confirm(+ "Bump the `latest` branch revision to #{ReleaseUtils::Version.current.next_revision}? This should only be done for security-fix merges which are not part of a regular monthly release.",+ )+ new_version = ReleaseUtils::Version.current.next_revision+ ReleaseUtils.write_version(new_version)+ ReleaseUtils.git "add", "lib/version.rb"+ ReleaseUtils.git "commit", "-m", "DEV: Bump development branch to v#{new_version}"+ end+puts "Finished merging commits into a locally-staged #{branch} branch. Git log is:"puts ReleaseUtils.git("log", "origin/#{base}..#{branch}")- ReleaseUtils.confirm "Check the log above. Ready to push this branch to the origin and create a PR?"+ ReleaseUtils.confirm_or_abort "Check the log above. Ready to push this branch to the origin and create a PR?"ReleaseUtils.git("push", "-f", "--set-upstream", "origin", branch)ReleaseUtils.make_pr(diff --git a/spec/lib/release_utils/version_spec.rb b/spec/lib/release_utils/version_spec.rbnew file mode 100644index 00000000000..5cd8be75b09--- /dev/null+++ b/spec/lib/release_utils/version_spec.rb@@ -0,0 +1,375 @@+# frozen_string_literal: true++require "release_utils/version"++RSpec.describe ReleaseUtils::Version do+ describe ".new" do+ subject(:version) { described_class.new(version_string) }++ context "with a release version" do+ let(:version_string) { "2025.10.1" }++ it do+ is_expected.to have_attributes(major: 2025, minor: 10, patch: 1, pre: nil, revision: nil)+ end+ end++ context "with a development version" do+ let(:version_string) { "2025.10.0-latest" }++ it do+ is_expected.to have_attributes(+ major: 2025,+ minor: 10,+ patch: 0,+ pre: "latest",+ revision: nil,+ )+ end+ end++ context "with a development version with revision" do+ let(:version_string) { "2025.10.0-latest.3" }++ it do+ is_expected.to have_attributes(major: 2025, minor: 10, patch: 0, pre: "latest", revision: 3)+ end+ end++ context "with a malformed version string" do+ let(:version_string) { "not-a-version" }++ it { expect { version }.to raise_error(ArgumentError) }+ end++ it "freezes the instance" do+ expect(described_class.new("2025.10.0")).to be_frozen+ end+ end++ describe ".current" do+ subject(:version) { described_class.current }++ before { allow(File).to receive(:read).with("lib/version.rb").and_return(version_rb) }++ context "with a valid version file" do+ let(:version_rb) { "STRING = \"2025.10.0-latest\"" }+ let(:expected_version) { described_class.new("2025.10.0-latest") }++ it { is_expected.to eq expected_version }+ end++ context "with no version string" do+ let(:version_rb) { "no version here" }++ it { expect { version }.to raise_error(RuntimeError, /Unable to parse/) }+ end+ end++ describe ".next" do+ subject(:next_version) { described_class.next }++ before do+ allow(File).to receive(:read).with("lib/version.rb").and_return(+ "STRING = \"#{current_version}\"",+ )+ end++ context "when current version is older than the target month" do+ let(:current_version) { "2025.1.0-latest" }++ it "jumps to the current month" do+ freeze_time "2025-09-15" do+ expect(next_version).to eq("2025.9.0-latest")+ end+ end+ end++ context "when current version matches the target month" do+ let(:current_version) { "2025.10.0-latest" }++ it "increments to the next month" do+ freeze_time "2025-10-15" do+ expect(next_version).to eq("2025.11.0-latest")+ end+ end+ end++ context "when current version is ahead of the target month" do+ let(:current_version) { "2025.11.0-latest" }++ it "increments to the next month" do+ freeze_time "2025-10-15" do+ expect(next_version).to eq("2025.12.0-latest")+ end+ end+ end++ context "when current version has a revision" do+ let(:current_version) { "2025.10.0-latest.2" }++ it "increments to the next month without revision" do+ freeze_time "2025-10-15" do+ expect(next_version).to eq("2025.11.0-latest")+ end+ end+ end++ context "when incrementing past December" do+ let(:current_version) { "2025.12.0-latest" }++ it "rolls over to next year" do+ freeze_time "2025-12-15" do+ expect(next_version).to eq("2026.1.0-latest")+ end+ end+ end+ end++ describe "#to_s" do+ subject(:version_string) { described_class.new(input).to_s }++ context "with a release version" do+ let(:input) { "2025.10.1" }++ it { is_expected.to eq("2025.10.1") }+ end++ context "with a development version" do+ let(:input) { "2025.10.0-latest" }++ it { is_expected.to eq("2025.10.0-latest") }+ end++ context "with a development version with revision" do+ let(:input) { "2025.10.0-latest.2" }++ it { is_expected.to eq("2025.10.0-latest.2") }+ end+ end++ describe "#<=>" do+ subject(:version) { described_class.new(version_string) }++ context "with release versions" do+ let(:version_string) { "2025.10.1" }++ it { is_expected.to be > described_class.new("2025.10.0") }+ it { is_expected.to be < described_class.new("2025.11.0") }+ it { is_expected.to eq described_class.new("2025.10.1") }+ end++ context "with a development version" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to be < described_class.new("2025.10.0") }+ end++ context "with development version revisions" do+ let(:version_string) { "2025.10.0-latest.2" }++ it { is_expected.to be > described_class.new("2025.10.0-latest.1") }+ it { is_expected.to be > described_class.new("2025.10.0-latest") }+ end++ context "with a string argument" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.to be > "2025.9.0" }+ end++ context "with an incompatible type" do+ let(:version_string) { "2025.10.0" }++ it { expect(version <=> 42).to be_nil }+ end+ end++ describe "#development?" do+ subject(:version) { described_class.new(version_string) }++ context "with a development version" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to be_development }+ end++ context "with a development version with revision" do+ let(:version_string) { "2025.10.0-latest.1" }++ it { is_expected.to be_development }+ end++ context "with a release version" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.not_to be_development }+ end+ end++ describe "#same_development_cycle?" do+ subject(:version) { described_class.new(version_string) }++ RSpec::Matchers.alias_matcher :share_development_cycle_with, :be_same_development_cycle++ context "with two development versions in the same cycle" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to share_development_cycle_with(described_class.new("2025.10.0-latest")) }+ end++ context "with development versions differing only in revision" do+ let(:version_string) { "2025.10.0-latest.1" }++ it { is_expected.to share_development_cycle_with(described_class.new("2025.10.0-latest.2")) }+ end++ context "with development versions in different cycles" do+ let(:version_string) { "2025.10.0-latest" }++ it do+ is_expected.not_to share_development_cycle_with(described_class.new("2025.11.0-latest"))+ end+ end++ context "when one version is a release" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.not_to share_development_cycle_with(described_class.new("2025.10.0")) }+ end++ context "when both versions are releases" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.not_to share_development_cycle_with(described_class.new("2025.10.0")) }+ end+ end++ describe "#same_series?" do+ subject(:version) { described_class.new(version_string) }++ RSpec::Matchers.alias_matcher :share_series_with, :be_same_series++ context "with versions in the same series" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.to share_series_with(described_class.new("2025.10.1")) }+ end++ context "with a release and development version in the same series" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.to share_series_with(described_class.new("2025.10.0-latest")) }+ end++ context "with versions in different series" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.not_to share_series_with(described_class.new("2025.11.0")) }+ end+ end++ describe "#series" do+ subject(:series) { described_class.new(version_string).series }++ context "with a release version" do+ let(:version_string) { "2025.10.3" }++ it { is_expected.to eq("2025.10") }+ end++ context "with a development version with revision" do+ let(:version_string) { "2025.10.0-latest.2" }++ it { is_expected.to eq("2025.10") }+ end+ end++ describe "#branch_name" do+ subject(:branch_name) { described_class.new("2025.10.0-latest").branch_name }++ it { is_expected.to eq("release/2025.10") }+ end++ describe "#tag_name" do+ subject(:tag_name) { described_class.new(version_string).tag_name }++ context "with a release version" do+ let(:version_string) { "2025.10.0" }++ it { is_expected.to eq("v2025.10.0") }+ end++ context "with a development version" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to eq("v2025.10.0-latest") }+ end++ context "with a development version with revision" do+ let(:version_string) { "2025.10.0-latest.2" }++ it { is_expected.to eq("v2025.10.0-latest.2") }+ end+ end++ describe "#without_revision" do+ subject(:without_revision) { version.without_revision }++ context "with a development version with revision" do+ let(:version) { described_class.new("2025.10.0-latest.2") }++ it { is_expected.to eq("2025.10.0-latest") }+ end++ context "with a development version without revision" do+ let(:version) { described_class.new("2025.10.0-latest") }++ it { is_expected.to equal(version) }+ end++ context "with a release version" do+ let(:version) { described_class.new("2025.10.0") }++ it { is_expected.to equal(version) }+ end+ end++ describe "#next_development_cycle" do+ subject(:next_version) { described_class.new(version_string).next_development_cycle }++ context "with a standard development version" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to eq("2025.11.0-latest") }+ end++ context "with December (year rollover)" do+ let(:version_string) { "2025.12.0-latest" }++ it { is_expected.to eq("2026.1.0-latest") }+ end++ context "with a development version with revision" do+ let(:version_string) { "2025.10.0-latest.2" }++ it { is_expected.to eq("2025.11.0-latest") }+ end+ end++ describe "#next_revision" do+ subject(:next_version) { described_class.new(version_string).next_revision }++ context "with a plain development version" do+ let(:version_string) { "2025.10.0-latest" }++ it { is_expected.to eq("2025.10.0-latest.1") }+ end++ context "with an existing revision" do+ let(:version_string) { "2025.10.0-latest.2" }++ it { is_expected.to eq("2025.10.0-latest.3") }+ end+ end+enddiff --git a/spec/tasks/release_spec.rb b/spec/tasks/release_spec.rbindex b073f840b26..68c7cb65475 100644--- a/spec/tasks/release_spec.rb+++ b/spec/tasks/release_spec.rb@@ -1,27 +1,35 @@# frozen_string_literal: true-def run(*args)- out, err, status = Open3.capture3(*args)- raise "Command failed: #{args.inspect}\n#{out}\n#{err}" unless status.success?- out-end--def fake_version_rb(version)- File.read("#{Rails.root}/lib/version.rb").sub(/STRING = ".*"/, "STRING = \"#{version}\"")-end-RSpec.describe "tasks/version_bump" dolet(:tmpdir) { Dir.mktmpdir }let(:origin_path) { "#{tmpdir}/origin-repo" }let(:local_path) { "#{tmpdir}/local-repo" }+ let(:git_tags) { git("tag").lines.map(&:strip) }++ def git(*args)+ out, err, status = Open3.capture3("git", *args)+ raise "Command failed: git #{args.inspect}\n#{out}\n#{err}" unless status.success?+ out+ end++ def fake_version_rb(version)+ File.read("#{Rails.root}/lib/version.rb").sub(/STRING = ".*"/, "STRING = \"#{version}\"")+ end++ def commit_version(version)+ File.write("lib/version.rb", fake_version_rb(version))+ git "add", "."+ git "commit", "-m", "version #{version}"+ git("rev-parse", "HEAD").strip+ enddef update_versions_json(overrides)Dir.chdir(origin_path) do- run "git", "checkout", "main"+ git "checkout", "main"current = JSON.parse(File.read("versions.json"))File.write("versions.json", JSON.pretty_generate(current.merge(overrides)))- run "git", "add", "versions.json"- run "git", "commit", "-m", "Update versions.json"+ git "add", "versions.json"+ git "commit", "-m", "Update versions.json"endend@@ -37,216 +45,161 @@ RSpec.describe "tasks/version_bump" doFile.write(".gitignore", "tmp\n")File.write("lib/version.rb", fake_version_rb("2025.12.0-latest"))- File.write(- "versions.json",- JSON.pretty_generate(- {- "2025.1" => {- "released" => true,- "esr" => true,- },- "2025.2" => {- "released" => true,- "esr" => false,- },- "2025.3" => {- "released" => true,- "esr" => false,- },- "2025.4" => {- "released" => true,- "esr" => false,- },- "2025.5" => {- "released" => true,- "esr" => false,- },- "2025.6" => {- "released" => true,- "esr" => false,- },- "2025.7" => {- "released" => false,- "esr" => true,- },- "2025.8" => {- "released" => false,- "esr" => false,- },- "2025.9" => {- "released" => false,- "esr" => false,- },- "2025.10" => {- "released" => false,- "esr" => false,- },- "2025.11" => {- "released" => false,- "esr" => false,- },- "2025.12" => {- "released" => false,- "esr" => false,- },- },- ),- )+ versions =+ (1..12).each_with_object({}) do |month, hash|+ hash["2025.#{month}"] = { "released" => month <= 6, "esr" => [1, 7].include?(month) }+ end+ File.write("versions.json", JSON.pretty_generate(versions))- run "git", "init"- run "git", "checkout", "-b", "main"- run "git", "add", "."- run "git", "commit", "-m", "Initial commit"+ git "init"+ git "checkout", "-b", "main"+ git "add", "."+ git "commit", "-m", "Initial commit"- run "git", "checkout", "-b", "stable"+ git "checkout", "-b", "stable"File.write("#{origin_path}/lib/version.rb", fake_version_rb("3.1.2"))- run "git", "add", "."- run "git", "commit", "-m", "Previous stable version bump"+ git "add", "."+ git "commit", "-m", "Previous stable version bump"- run "git", "checkout", "main"- run "git", "config", "receive.denyCurrentBranch", "ignore"+ git "checkout", "main"+ git "config", "receive.denyCurrentBranch", "ignore"end- run "git", "clone", "-b", "main", origin_path, local_path+ git "clone", "-b", "main", origin_path, local_pathendafter doFileUtils.remove_entry(tmpdir)- ENV.delete("RUNNING_VERSION_BUMP_IN_RSPEC_TESTS")+ ENV.delete("RUNNING_RELEASE_IN_RSPEC_TESTS")enddescribe "release:maybe_tag_release" do- it "does not tag if commit is not on a release/* branch" do- Dir.chdir(local_path) do- run "git", "switch", "-c", "some-other-branch"- File.write("lib/version.rb", fake_version_rb("2025.6.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.6.0"- commit_hash = run("git", "rev-parse", "HEAD").strip- # Not on a release/* branch, should not tag- capture_stdout { invoke_rake_task("release:maybe_tag_release", commit_hash) }- # Should not tag, so v2025.6.0 should not exist- expect(run("git", "tag").lines.map(&:strip)).not_to include("v2025.6.0")- end+ subject(:run_task) do+ capture_stdout { invoke_rake_task("release:maybe_tag_release", commit_hash) }end- it "tags a release if tag does not exist" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.3.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.3.0"- commit_hash = run("git", "rev-parse", "HEAD").strip- run "git", "branch", "release/2025.3"- output = capture_stdout { invoke_rake_task("release:maybe_tag_release", commit_hash) }- expect(output).to include("Tagging release v2025.3.0")- expect(run("git", "tag").lines.map(&:strip)).to include("v2025.3.0")+ let(:commit_hash) { commit_version(version) }++ context "when commit is not on a release branch" do+ let(:version) { "2025.6.0" }++ it "does not create a tag" do+ Dir.chdir(local_path) do+ git "switch", "-c", "some-other-branch"++ expect { run_task }.not_to change { git_tags }+ endendend- it "tags first commit of a pre-release cycle" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.4.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "bump to 2025.4.0-latest"- commit_hash = run("git", "rev-parse", "HEAD").strip- output = capture_stdout { invoke_rake_task("release:maybe_tag_release", commit_hash) }- expect(output).to include("Tagging release v2025.4.0-latest")- expect(run("git", "tag").lines.map(&:strip)).to include("v2025.4.0-latest")+ context "when tag does not exist" do+ let(:version) { "2025.3.0" }+ let!(:commit_hash) { Dir.chdir(local_path) { commit_version(version) } }++ it "creates the tag" do+ Dir.chdir(local_path) do+ git "branch", "release/2025.3"++ expect(run_task).to include("Tagging release v2025.3.0")+ expect(git_tags).to include("v2025.3.0")+ endendend- it "skips tagging if tag already exists" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.5.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.5.0"- commit_hash = run("git", "rev-parse", "HEAD").strip- run "git", "branch", "release/2025.5"- # Create tag manually- run "git", "tag", "-a", "v2025.5.0", "-m", "version 2025.5.0"- output = capture_stdout { invoke_rake_task("release:maybe_tag_release", commit_hash) }- expect(output).to include("Tag v2025.5.0 already exists, skipping")+ context "when version is a pre-release" do+ let(:version) { "2025.4.0-latest" }++ it "tags the pre-release version" do+ Dir.chdir(local_path) do+ expect(run_task).to include("Tagging release v2025.4.0-latest")+ expect(git_tags).to include("v2025.4.0-latest")+ endendend- end-- describe "release:update_release_tags" do- it "creates release alias tags when version matches latest release" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.6.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.6.0"- commit_hash = run("git", "rev-parse", "HEAD").strip- capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ context "when version is a security patchlevel" do+ let(:version) { "2025.4.0-latest.1" }- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::RELEASE_TAGS.each { |tag| expect(tags).to include(tag) }+ it "tags the patchlevel version" do+ Dir.chdir(local_path) do+ expect(run_task).to include("Tagging release v2025.4.0-latest.1")+ expect(git_tags).to include("v2025.4.0-latest.1")+ endendend- it "skips release tags when version is older than latest release" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.1.0"))- run "git", "add", "."- run "git", "commit", "-m", "old release"- commit_hash = run("git", "rev-parse", "HEAD").strip+ context "when tag already exists" do+ let(:version) { "2025.5.0" }+ let!(:commit_hash) { Dir.chdir(local_path) { commit_version(version) } }- output = capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ it "skips tagging" do+ Dir.chdir(local_path) do+ git "branch", "release/2025.5"+ git "tag", "-a", "v2025.5.0", "-m", "version 2025.5.0"- expect(output).to include("older than latest release")- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::RELEASE_TAGS.each { |tag| expect(tags).not_to include(tag) }+ expect { run_task }.not_to change { git_tags }+ endendend+ end- it "ignores unreleased versions when determining latest release" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.6.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.6.0"- commit_hash = run("git", "rev-parse", "HEAD").strip+ describe "release:update_release_tags" do+ subject(:run_task) do+ capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ end- capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ let(:commit_hash) { commit_version(version) }- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::RELEASE_TAGS.each { |tag| expect(tags).to include(tag) }+ context "when version is newer than latest release" do+ let(:version) { "2025.6.0" }++ it "creates release alias tags" do+ Dir.chdir(local_path) do+ run_task+ expect(git_tags).to contain_exactly(*ReleaseUtils::RELEASE_TAGS)+ endendend- it "does not create ESR tags for non-ESR releases" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.6.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.6.0"- commit_hash = run("git", "rev-parse", "HEAD").strip-- capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ context "when version is older than latest release" do+ let(:version) { "2025.1.0" }- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::ESR_TAGS.each { |tag| expect(tags).not_to include(tag) }+ it "skips release tags" do+ Dir.chdir(local_path) do+ expect(run_task).to include("older than latest release")+ expect(git_tags).not_to include(*ReleaseUtils::RELEASE_TAGS)+ endendend- it "creates ESR alias tags when version is in the latest released ESR series" do- Dir.chdir(local_path) do- update_versions_json({ "2025.7" => { "released" => true, "esr" => true } })+ context "when version is a non-ESR release" do+ let(:version) { "2025.6.0" }- File.write("lib/version.rb", fake_version_rb("2025.7.1"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.7.1"- commit_hash = run("git", "rev-parse", "HEAD").strip+ it "does not create ESR tags" do+ Dir.chdir(local_path) do+ run_task+ expect(git_tags).not_to include(*ReleaseUtils::ESR_TAGS)+ end+ end+ end- capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }+ context "when version is in the latest released ESR series" do+ let(:version) { "2025.7.1" }- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::RELEASE_TAGS.each { |tag| expect(tags).to include(tag) }- ReleaseUtils::ESR_TAGS.each { |tag| expect(tags).to include(tag) }+ before { update_versions_json({ "2025.7" => { "released" => true, "esr" => true } }) }++ it "creates both release and ESR alias tags" do+ Dir.chdir(local_path) do+ run_task+ expect(git_tags).to include(*ReleaseUtils::RELEASE_TAGS, *ReleaseUtils::ESR_TAGS)+ endendend- it "does not add ESR tags to non-ESR releases newer than the latest ESR" do- Dir.chdir(local_path) do+ context "when version is newer than the latest ESR but not an ESR itself" do+ let(:version) { "2025.8.0" }++ before doupdate_versions_json({"2025.7" => {@@ -259,119 +212,222 @@ RSpec.describe "tasks/version_bump" do},},)+ end- File.write("lib/version.rb", fake_version_rb("2025.8.0"))- run "git", "add", "."- run "git", "commit", "-m", "release 2025.8.0"- commit_hash = run("git", "rev-parse", "HEAD").strip-- capture_stdout { invoke_rake_task("release:update_release_tags", commit_hash) }-- tags = run("git", "tag").lines.map(&:strip)- ReleaseUtils::RELEASE_TAGS.each { |tag| expect(tags).to include(tag) }- ReleaseUtils::ESR_TAGS.each { |tag| expect(tags).not_to include(tag) }+ it "creates release tags but not ESR tags" do+ Dir.chdir(local_path) do+ run_task+ expect(git_tags).to contain_exactly(*ReleaseUtils::RELEASE_TAGS)+ endendendend- it "can create a new release branch" do- latest_hash, previous_hash = nil+ describe "release:maybe_cut_branch" do+ subject(:run_task) do+ capture_stdout { invoke_rake_task("release:maybe_cut_branch", latest_hash) }+ end++ context "when development cycle changes" do+ let!(:previous_hash) { Dir.chdir(local_path) { commit_version(previous_version) } }+ let!(:latest_hash) { Dir.chdir(local_path) { commit_version(current_version) } }++ def branch_tip(branch)+ Dir.chdir(origin_path) do+ git "checkout", branch+ git("rev-parse", "HEAD").strip+ end+ end++ context "when going from one minor to another" do+ let(:previous_version) { "2025.1.0-latest" }+ let(:current_version) { "2025.2.0-latest" }- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.1.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "developing 2025.1"+ it "creates a release branch at the previous commit" do+ Dir.chdir(local_path) { run_task }- previous_hash = run("git", "rev-parse", "HEAD").strip+ expect(branch_tip("release/2025.1")).to eq(previous_hash)+ end+ end- File.write("lib/version.rb", fake_version_rb("2025.2.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "begin development of 2025.2-latest"+ context "when going from a patchlevel to a new minor" do+ let(:previous_version) { "2025.11.0-latest.2" }+ let(:current_version) { "2025.12.0-latest" }- latest_hash = run("git", "rev-parse", "HEAD").strip+ it "creates a release branch at the previous commit" do+ Dir.chdir(local_path) { run_task }- output = capture_stdout { invoke_rake_task("release:maybe_cut_branch", latest_hash) }- expect(output).to include("Created new branch")+ expect(branch_tip("release/2025.11")).to eq(previous_hash)+ end+ endend- Dir.chdir(origin_path) do- run "git", "checkout", "release/2025.1"- branch_tip = run("git", "rev-parse", "HEAD").strip- expect(branch_tip).to eq(previous_hash)+ context "when development cycle stays the same" do+ def origin_branches+ Dir.chdir(origin_path) { git("branch").lines.map(&:strip) }+ end++ context "when bumping from latest to latest.1" do+ let!(:latest_hash) { Dir.chdir(local_path) { commit_version("2025.12.0-latest.1") } }++ it "does not create a branch" do+ Dir.chdir(local_path) { expect { run_task }.not_to change { origin_branches } }+ end+ end++ context "when bumping from latest.1 to latest.2" do+ let!(:intermediate_hash) { Dir.chdir(local_path) { commit_version("2025.12.0-latest.1") } }+ let!(:latest_hash) { Dir.chdir(local_path) { commit_version("2025.12.0-latest.2") } }++ it "does not create a branch" do+ Dir.chdir(local_path) { expect { run_task }.not_to change { origin_branches } }+ end+ endendenddescribe "release:prepare_next_version" do- it "bumps version to current month format when current version is older" do+ subject(:run_task) doDir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2024.1.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "old version"- run "git", "push", "origin", "main"-- freeze_time Time.utc(2025, 9, 15) do+ freeze_time(frozen_time) docapture_stdout { invoke_rake_task("release:prepare_next_version") }endend+ end++ let(:bumped_version) do+ on_version_bump_branch { File.read("lib/version.rb")[/STRING = "(.*)"/, 1] }+ end+ def on_version_bump_branchDir.chdir(origin_path) do- run "git", "reset", "--hard"- run "git", "checkout", "version-bump/main"- version_rb_content = File.read("lib/version.rb")- expect(version_rb_content).to include('STRING = "2025.9.0-latest"')+ git "reset", "--hard"+ git "checkout", "version-bump/main"+ yieldendend- it "increments minor version when current version is already >= target month version" do- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.10.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "current month version"- run "git", "push", "origin", "main"-- freeze_time Time.utc(2025, 10, 15) do- output = capture_stdout { invoke_rake_task("release:prepare_next_version") }- expect(output).to include("is already >= 2025.10.0-latest. Incrementing instead.")+ context "with a custom version on main" do+ before do+ Dir.chdir(local_path) do+ commit_version(initial_version)+ git "push", "origin", "main"endend- Dir.chdir(origin_path) do- run "git", "reset", "--hard"- run "git", "checkout", "version-bump/main"- version_rb_content = File.read("lib/version.rb")- expect(version_rb_content).to include('STRING = "2025.11.0-latest"')+ context "when current version is older than target month" do+ let(:frozen_time) { "2025-09-15" }+ let(:initial_version) { "2024.1.0-latest" }++ it "bumps to the current month" do+ run_task+ expect(bumped_version).to eq("2025.9.0-latest")+ endend- end- it "rolls over to next year when incrementing past December" do- Dir.chdir(local_path) do- freeze_time Time.utc(2025, 12, 15) do- capture_stdout { invoke_rake_task("release:prepare_next_version") }+ context "when current version matches target month" do+ let(:frozen_time) { "2025-10-15" }+ let(:initial_version) { "2025.10.0-latest" }++ it "increments to next month" do+ run_task+ expect(bumped_version).to eq("2025.11.0-latest")endend- Dir.chdir(origin_path) do- run "git", "reset", "--hard"- run "git", "checkout", "version-bump/main"- version_rb_content = File.read("lib/version.rb")- expect(version_rb_content).to include('STRING = "2026.1.0-latest"')+ context "when current version has a security patchlevel" do+ let(:frozen_time) { "2025-10-15" }+ let(:initial_version) { "2025.10.0-latest.2" }++ it "increments to next month and drops patchlevel" do+ run_task+ expect(bumped_version).to eq("2025.11.0-latest")+ endend- end- it "updates versions.json with new version info" do- Dir.chdir(local_path) do- freeze_time Time.utc(2025, 12, 28) do- capture_stdout { invoke_rake_task("release:prepare_next_version") }+ context "when PR creation succeeds" do+ let(:frozen_time) { "2025-10-15" }+ let(:initial_version) { "2025.5.0-latest" }+ let(:commit_message) { on_version_bump_branch { git("log", "-1", "--pretty=%B").strip } }++ before do+ allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(true)+ run_task+ end++ it "includes the version bump description" do+ expect(commit_message).to include("Begin development of v2025.10.0-latest")+ expect(commit_message).to include(+ "Merging this will trigger the creation of a `release/2025.5` branch on the preceding commit.",+ )+ end++ it "creates a PR" do+ commit_message++ expect(ReleaseUtils).to have_received(:gh).with(+ "pr",+ "create",+ "--base",+ "main",+ "--head",+ "version-bump/main",+ "--title",+ "DEV: Begin development of v2025.10.0-latest",+ "--body",+ a_string_including(+ "Merging this will trigger the creation of a `release/2025.5` branch",+ ),+ "--label",+ ReleaseUtils::PR_LABEL,+ )endend- Dir.chdir(origin_path) do- run "git", "reset", "--hard"- run "git", "checkout", "version-bump/main"- version_rb_content = File.read("lib/version.rb")- expect(version_rb_content).to include('STRING = "2026.1.0-latest"')+ context "when PR creation fails" do+ let(:frozen_time) { "2025-10-15" }+ let(:initial_version) { "2025.5.0-latest" }++ before do+ allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(false)+ allow(ReleaseUtils).to receive(:gh).with("pr", "edit", any_args).and_return(true)+ end- versions_json = JSON.parse(File.read("versions.json"))+ it "falls back to editing the PR" do+ run_task++ expect(ReleaseUtils).to have_received(:gh).with(+ "pr",+ "edit",+ "version-bump/main",+ "--title",+ "DEV: Begin development of v2025.10.0-latest",+ "--body",+ a_string_including(+ "Merging this will trigger the creation of a `release/2025.5` branch",+ ),+ "--add-label",+ ReleaseUtils::PR_LABEL,+ )+ end+ end+ end++ context "when incrementing past December" do+ let(:frozen_time) { "2025-12-15" }++ it "rolls over to next year" do+ run_task+ expect(bumped_version).to eq("2026.1.0-latest")+ end+ end++ context "when updating versions.json" do+ let(:frozen_time) { "2025-12-28" }+ let(:versions_json) { on_version_bump_branch { JSON.parse(File.read("versions.json")) } }++ it "adds new version entry" do+ run_taskexpect(versions_json["2026.1"]).to eq({"developmentStartDate" => "2025-12-28",@@ -382,113 +438,87 @@ RSpec.describe "tasks/version_bump" do"supported" => true,},)- expect(versions_json["2025.12"]["released"]).to eq(true)- expect(versions_json["2025.12"]["releaseDate"]).to eq("2025-12-28")- end- end-- it "creates version-bump/main branch with proper commit message and PR" do- allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(true)-- Dir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.5.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "previous version"- run "git", "push", "origin", "main"-- freeze_time Time.utc(2025, 10, 15) do- capture_stdout { invoke_rake_task("release:prepare_next_version") }- endend- Dir.chdir(origin_path) do- run "git", "reset", "--hard"- run "git", "checkout", "version-bump/main"- current_branch = run("git", "branch", "--show-current").strip- expect(current_branch).to eq("version-bump/main")-- commit_message = run("git", "log", "-1", "--pretty=%B").strip- expect(commit_message).to include("Begin development of v2025.10.0-latest")- expect(commit_message).to include(- "Merging this will trigger the creation of a `release/2025.5` branch on the preceding commit.",+ it "marks previous version as released" do+ run_task+ expect(versions_json["2025.12"]).to include(+ "released" => true,+ "releaseDate" => "2025-12-28",)end-- expect(ReleaseUtils).to have_received(:gh).with(- "pr",- "create",- "--base",- "main",- "--head",- "version-bump/main",- "--title",- "DEV: Begin development of v2025.10.0-latest",- "--body",- a_string_including("Merging this will trigger the creation of a `release/2025.5` branch"),- "--label",- ReleaseUtils::PR_LABEL,- )end+ end- it "falls back to editing PR if create fails" do- allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(false)- allow(ReleaseUtils).to receive(:gh).with("pr", "edit", any_args).and_return(true)-+ describe "release:stage_security_fixes" do+ subject(:run_task) doDir.chdir(local_path) do- File.write("lib/version.rb", fake_version_rb("2025.5.0-latest"))- run "git", "add", "."- run "git", "commit", "-m", "previous version"- run "git", "push", "origin", "main"-- freeze_time Time.utc(2025, 10, 15) do- capture_stdout { invoke_rake_task("release:prepare_next_version") }- end+ capture_stdout { invoke_rake_task("release:stage_security_fixes", "main") }end+ end- expect(ReleaseUtils).to have_received(:gh).with(- "pr",- "edit",- "version-bump/main",- "--title",- "DEV: Begin development of v2025.10.0-latest",- "--body",- a_string_including("Merging this will trigger the creation of a `release/2025.5` branch"),- "--add-label",- ReleaseUtils::PR_LABEL,- )+ let(:origin_main_commits) do+ Dir.chdir(origin_path) { git("log", "--pretty=%s", "main").lines.map(&:strip) }end- end- describe "release:stage_security_fixes" do- it "stages a PR of multiple security fixes" do- Dir.chdir(origin_path) do- run "git", "checkout", "-b", "security-fix-one"+ def origin_file(path)+ Dir.chdir(origin_path) { git("show", "main:#{path}") }+ end+ before do+ ENV["SECURITY_FIX_REFS"] = "origin/security-fix-one,origin/security-fix-two"+ Dir.chdir(origin_path) do+ git "checkout", "-b", "security-fix-one"File.write("firstfile.txt", "contents")- run "git", "add", "firstfile.txt"- run "git", "-c", "commit.gpgsign=false", "commit", "-m", "security fix one, commit one"+ git "add", "firstfile.txt"+ git "-c", "commit.gpgsign=false", "commit", "-m", "security fix one, commit one"File.write("secondfile.txt", "contents")- run "git", "add", "secondfile.txt"- run "git", "-c", "commit.gpgsign=false", "commit", "-m", "security fix one, commit two"-- run "git", "checkout", "main"- run "git", "checkout", "-b", "security-fix-two"+ git "add", "secondfile.txt"+ git "-c", "commit.gpgsign=false", "commit", "-m", "security fix one, commit two"+ git "checkout", "main"+ git "checkout", "-b", "security-fix-two"File.write("somefile.txt", "contents")- run "git", "add", "somefile.txt"- run "git", "-c", "commit.gpgsign=false", "commit", "-m", "security fix two"+ git "add", "somefile.txt"+ git "-c", "commit.gpgsign=false", "commit", "-m", "security fix two"end+ end- Dir.chdir(local_path) do- capture_stdout do- ENV["SECURITY_FIX_REFS"] = "origin/security-fix-one,origin/security-fix-two"- invoke_rake_task("release:stage_security_fixes", "main")- ensure- ENV.delete("SECURITY_FIX_REFS")- end+ after { ENV.delete("SECURITY_FIX_REFS") }++ context "when accepting the version bump" do+ before { run_task }++ it "cherry-picks all security fix commits in order" do+ expect(origin_main_commits).to eq(+ [+ "DEV: Bump development branch to v2025.12.0-latest.1",+ "security fix two",+ "security fix one, commit two",+ "security fix one, commit one",+ "Initial commit",+ ],+ )end- Dir.chdir(origin_path) do- expect(run("git", "log", "--pretty=%s", "main").lines.map(&:strip)).to eq(+ it "includes files from all security fixes" do+ expect(origin_file("firstfile.txt")).to eq("contents")+ expect(origin_file("secondfile.txt")).to eq("contents")+ expect(origin_file("somefile.txt")).to eq("contents")+ end++ it "bumps the development version" do+ expect(origin_file("lib/version.rb")).to include('STRING = "2025.12.0-latest.1"')+ end+ end++ context "when declining the version bump" do+ before do+ allow(ReleaseUtils).to receive(:confirm).and_return(false)+ run_task+ end++ it "cherry-picks security fix commits without a version bump" do+ expect(origin_main_commits).to eq(["security fix two","security fix one, commit two",@@ -496,10 +526,10 @@ RSpec.describe "tasks/version_bump" do"Initial commit",],)+ end- expect(run("git", "show", "main:somefile.txt")).to eq("contents")- expect(run("git", "show", "main:firstfile.txt")).to eq("contents")- expect(run("git", "show", "main:secondfile.txt")).to eq("contents")+ it "does not modify the version" do+ expect(origin_file("lib/version.rb")).to include('STRING = "2025.12.0-latest"')endendend