diff options
Diffstat (limited to 'lib/bundler/gem_helper.rb')
-rw-r--r-- | lib/bundler/gem_helper.rb | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 272e7ecb69..4ada36aef4 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -32,7 +32,7 @@ module Bundler 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")] + gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : Gem::Util.glob_files_in_dir("{,*}.gemspec", @base) 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) @@ -100,27 +100,35 @@ module Bundler Bundler.ui.confirm "#{name} (#{version}) installed." end - protected + protected def rubygem_push(path) cmd = [*gem_command, "push", path] cmd << "--key" << gem_key if gem_key cmd << "--host" << allowed_push_host if allowed_push_host - unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file? - raise "Your rubygems.org credentials aren't set. Run `gem signin` to set them." - end sh_with_input(cmd) Bundler.ui.confirm "Pushed #{name} #{version} to #{gem_push_host}" end def built_gem_path - Dir[File.join(base, "#{name}-*.gem")].sort_by {|f| File.mtime(f) }.last + Gem::Util.glob_files_in_dir("#{name}-*.gem", base).sort_by {|f| File.mtime(f) }.last end - def git_push(remote = "") + def git_push(remote = nil) + remote ||= default_remote perform_git_push remote - perform_git_push "#{remote} --tags" - Bundler.ui.confirm "Pushed git commits and tags." + perform_git_push "#{remote} #{version_tag}" + Bundler.ui.confirm "Pushed git commits and release tag." + end + + def default_remote + current_branch = sh(%w[git rev-parse --abbrev-ref HEAD]).strip + return "origin" if current_branch.empty? + + remote_for_branch = sh(%W[git config --get branch.#{current_branch}.remote]).strip + return "origin" if remote_for_branch.empty? + + remote_for_branch end def allowed_push_host |