From 13bd2b43f33abda2762e7e668e1fc9248e4fb928 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Tue, 14 Jun 2016 16:32:56 -0700 Subject: Change Rakefile to work as a submodule --- Rakefile | 27 ++++++++++++++++++--------- spec/runtime/setup_spec.rb | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index 9bc34e41..09c27f99 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,12 @@ $:.unshift File.expand_path("../lib", __FILE__) require "shellwords" require "benchmark" -RUBYGEMS_REPO = File.expand_path("tmp/rubygems") +RUBYGEMS_REPO = if `cd .. && git remote --verbose` =~ /rubygems/i + File.expand_path("..") +else + File.expand_path("tmp/rubygems") +end + BUNDLER_SPEC = Gem::Specification.load("bundler.gemspec") def safe_task(&block) @@ -142,18 +147,22 @@ begin end hash = nil - Dir.chdir(RUBYGEMS_REPO) do - system("git remote update") - if rg == "master" - system("git checkout origin/master") - else - system("git checkout #{rg}") || raise("Unknown Rubygems ref #{rg}") + if RUBYGEMS_REPO.start_with?(Dir.pwd) + Dir.chdir(RUBYGEMS_REPO) do + system("git remote update") + if rg == "master" + system("git checkout origin/master") + else + system("git checkout #{rg}") || raise("Unknown Rubygems ref #{rg}") + end + hash = `git rev-parse HEAD`.chomp end - hash = `git rev-parse HEAD`.chomp + elsif rg != "master" + raise "need to be running against master with bundler as a submodule" end puts "Checked out rubygems '#{rg}' at #{hash}" - ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems/lib")} #{rubyopt}" + ENV["RUBYOPT"] = "-I#{File.join(RUBYGEMS_REPO, "lib")} #{rubyopt}" puts "RUBYOPT=#{ENV["RUBYOPT"]}" end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 14377ed1..aa74d83b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -151,6 +151,7 @@ describe "Bundler.setup" do bundler_path.to_s, bundler_path.join("gems/bundler-#{Bundler::VERSION}/lib").to_s, tmp("rubygems/lib").to_s, + root.join("../lib").expand_path.to_s, ] load_path.map! {|lp| lp.sub(/^#{system_gem_path}/, "") } -- cgit v1.2.3 From d492047839c3714613a32f9be32ab3b3817539e7 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 20 Jun 2016 22:53:32 -0500 Subject: [PostItTrampoline] Support for running as a default spec --- lib/bundler/postit_trampoline.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/bundler/postit_trampoline.rb b/lib/bundler/postit_trampoline.rb index 7406612e..50bfee66 100644 --- a/lib/bundler/postit_trampoline.rb +++ b/lib/bundler/postit_trampoline.rb @@ -29,9 +29,12 @@ The error was: #{e} EOS end - Gem.loaded_specs.delete("bundler") unless defined?(Bundler) + if deleted_spec = Gem.loaded_specs.delete("bundler") + deleted_spec.full_require_paths.each {|path| $:.delete(path) } + else + $:.delete(File.expand_path("../..", __FILE__)) + end gem "bundler", version - $:.delete(File.expand_path("../..", __FILE__)) else begin gem "bundler", version -- cgit v1.2.3