1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Let update_git work with whatever branch is checkout out

Unless the `:branch` option is passed.

It's more efficient, and it results in less hardcoding of "master".

https://github.com/rubygems/rubygems/commit/aa5c3409ab
This commit is contained in:
David Rodríguez 2021-10-08 13:05:31 +02:00 committed by Hiroshi SHIBATA
parent 5a34b639fc
commit a5bae843ff
2 changed files with 3 additions and 11 deletions

View file

@ -553,17 +553,9 @@ module Spec
update_gemspec = options[:gemspec] || false
source = options[:source] || "git@#{libpath}"
@context.git "checkout master", libpath
if branch = options[:branch]
raise "You can't specify `master` as the branch" if branch == "master"
escaped_branch = Shellwords.shellescape(branch)
if @context.git("branch --list #{escaped_branch}", libpath).empty?
@context.git("branch #{escaped_branch}", libpath)
end
@context.git("checkout #{escaped_branch}", libpath)
@context.git("checkout -b #{Shellwords.shellescape(branch)}", libpath)
elsif tag = options[:tag]
@context.git("tag #{Shellwords.shellescape(tag)}", libpath)
elsif options[:remote]

View file

@ -13,7 +13,7 @@ RSpec.describe "bundle update" do
end
G
update_git "foo", :branch => "omg" do |s|
update_git "foo" do |s|
s.write "lib/foo.rb", "FOO = '1.1'"
end
@ -48,7 +48,7 @@ RSpec.describe "bundle update" do
end
G
update_git "foo", :branch => "omg", :path => lib_path("foo") do |s|
update_git "foo", :path => lib_path("foo") do |s|
s.write "lib/foo.rb", "FOO = '1.1'"
end