Skip to content

Commit

Permalink
Let update_git work with whatever branch is checkout out
Browse files Browse the repository at this point in the history
Unless the `:branch` option is passed.

It's more efficient, and it results in less hardcoding of "master".
  • Loading branch information
deivid-rodriguez committed Oct 8, 2021
1 parent 979d163 commit aa5c340
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions bundler/spec/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,9 @@ def _build(options)
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]
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/update/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end
G

update_git "foo", :branch => "omg" do |s|
update_git "foo" do |s|
s.write "lib/foo.rb", "FOO = '1.1'"
end

Expand Down Expand Up @@ -48,7 +48,7 @@
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

Expand Down

0 comments on commit aa5c340

Please sign in to comment.