mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Allow setting a tag prefix to be used by gem release tasks
https://github.com/rubygems/rubygems/commit/679008f23a
This commit is contained in:
parent
ca133c0366
commit
4f9c673cab
Notes:
git
2020-07-15 16:05:45 +09:00
2 changed files with 25 additions and 1 deletions
|
@ -15,6 +15,10 @@ module Bundler
|
||||||
new(opts[:dir], opts[:name]).install
|
new(opts[:dir], opts[:name]).install
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tag_prefix=(prefix)
|
||||||
|
instance.tag_prefix = prefix
|
||||||
|
end
|
||||||
|
|
||||||
def gemspec(&block)
|
def gemspec(&block)
|
||||||
gemspec = instance.gemspec
|
gemspec = instance.gemspec
|
||||||
block.call(gemspec) if block
|
block.call(gemspec) if block
|
||||||
|
@ -24,12 +28,15 @@ module Bundler
|
||||||
|
|
||||||
attr_reader :spec_path, :base, :gemspec
|
attr_reader :spec_path, :base, :gemspec
|
||||||
|
|
||||||
|
attr_writer :tag_prefix
|
||||||
|
|
||||||
def initialize(base = nil, name = nil)
|
def initialize(base = nil, name = nil)
|
||||||
@base = File.expand_path(base || SharedHelpers.pwd)
|
@base = File.expand_path(base || SharedHelpers.pwd)
|
||||||
gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : Dir[File.join(@base, "{,*}.gemspec")]
|
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
|
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
|
@spec_path = gemspecs.first
|
||||||
@gemspec = Bundler.load_gemspec(@spec_path)
|
@gemspec = Bundler.load_gemspec(@spec_path)
|
||||||
|
@tag_prefix = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
|
@ -168,7 +175,7 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
def version_tag
|
def version_tag
|
||||||
"v#{version}"
|
"#{@tag_prefix}v#{version}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
|
|
|
@ -258,6 +258,23 @@ RSpec.describe Bundler::GemHelper do
|
||||||
end
|
end
|
||||||
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
|
it "even if tag already exists" do
|
||||||
mock_build_message app_name, app_version
|
mock_build_message app_name, app_version
|
||||||
mock_confirm_message "Tag v#{app_version} has already been created."
|
mock_confirm_message "Tag v#{app_version} has already been created."
|
||||||
|
|
Loading…
Reference in a new issue