[前][次][番号順一覧][スレッド一覧]

ruby-changes:62247

From: David <ko1@a...>
Date: Wed, 15 Jul 2020 16:06:06 +0900 (JST)
Subject: [ruby-changes:62247] 4f9c673cab (master): [rubygems/rubygems] Allow setting a tag prefix to be used by gem release tasks

https://git.ruby-lang.org/ruby.git/commit/?id=4f9c673cab

From 4f9c673cabcf9ae1d7ac2aa9d4a632f41ae76e38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Mon, 22 Jun 2020 12:41:13 +0200
Subject: [rubygems/rubygems] Allow setting a tag prefix to be used by gem
 release tasks

https://github.com/rubygems/rubygems/commit/679008f23a

diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index eab8946..272e7ec 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -15,6 +15,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/gem_helper.rb#L15
         new(opts[:dir], opts[:name]).install
       end
 
+      def tag_prefix=(prefix)
+        instance.tag_prefix = prefix
+      end
+
       def gemspec(&block)
         gemspec = instance.gemspec
         block.call(gemspec) if block
@@ -24,12 +28,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/gem_helper.rb#L28
 
     attr_reader :spec_path, :base, :gemspec
 
+    attr_writer :tag_prefix
+
     def initialize(base = nil, name = nil)
       @base = File.expand_path(base || SharedHelpers.pwd)
       gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : Dir[File.join(@base, "{,*}.gemspec")]
       raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
       @spec_path = gemspecs.first
       @gemspec = Bundler.load_gemspec(@spec_path)
+      @tag_prefix = ""
     end
 
     def install
@@ -168,7 +175,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/gem_helper.rb#L175
     end
 
     def version_tag
-      "v#{version}"
+      "#{@tag_prefix}v#{version}"
     end
 
     def name
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index 6cb4c33..b91a2c2 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -258,6 +258,23 @@ RSpec.describe Bundler::GemHelper do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/gem_helper_spec.rb#L258
           end
         end
 
+        context "on releasing with a custom tag prefix" do
+          before do
+            Bundler::GemHelper.tag_prefix = "foo-"
+            mock_build_message app_name, app_version
+            mock_confirm_message "Pushed git commits and tags."
+
+            sys_exec("git push -u origin master", :dir => app_path)
+            expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
+          end
+
+          it "prepends the custom prefix to the tag" do
+            mock_confirm_message "Tagged foo-v#{app_version}."
+
+            Rake.application["release"].invoke
+          end
+        end
+
         it "even if tag already exists" do
           mock_build_message app_name, app_version
           mock_confirm_message "Tag v#{app_version} has already been created."
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]