Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge branch '1-0-stable'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/bundler/version.rb
  • Loading branch information
hone committed Jan 21, 2011
2 parents 02b3142 + f2ca897 commit 8161a70
Show file tree
Hide file tree
Showing 26 changed files with 249 additions and 40 deletions.
32 changes: 30 additions & 2 deletions CHANGELOG.md
@@ -1,3 +1,33 @@
## 1.0.9 (January 19, 2010)

Bugfixes:

- Fix a bug where Bundler.require could remove gems from the load
path. In Rails apps with a default application.rb, this removed
all gems in groups other than :default and Rails.env.

## 1.0.8 (January 18, 2010)

Features:

- Allow overriding gemspec() deps with :git deps
- Add --local option to `bundle update`
- Ignore Gemfile.lock in newly generated gems
- Use `less` as help pager instead of `more`
- Run `bundle exec rake` instead of `rake` in Capistrano tasks

Bugfixes:

- Fix --no-cache option for `bundle install`
- Allow Vlad deploys to work without Capistrano gem installed
- Fix group arguments to `bundle console`
- Allow groups to be loaded even if other groups were loaded
- Evaluate gemspec() gemspecs in their directory not the cwd
- Count on Rake to chdir to the right place in GemHelper
- Change Pathnames to Strings for MacRuby
- Check git process exit status correctly
- Fix some warnings in 1.9.3-trunk (thanks tenderlove)

## 1.0.7 (November 17, 2010)

Bugfixes:
Expand Down Expand Up @@ -290,8 +320,6 @@ isolation.
- Fix cases where the same dependency appeared several times in the Gemfile.lock
- Fix a bug where require errors were being swallowed during Bundler.require

## BACKFILL COMING

## 1.0.0.beta.1

- No `bundle lock` command. Locking happens automatically on install or update
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -60,7 +60,7 @@ begin
namespace :rubygems do
# Rubygems 1.3.5, 1.3.6, and HEAD specs
rubyopt = ENV["RUBYOPT"]
%w(master REL_1_3_5 REL_1_3_6).each do |rg|
%w(master v1.3.5 v1.3.6 v1.3.7 v1.4.0 v1.4.1).each do |rg|
desc "Run specs with Rubygems #{rg}"
RSpec::Core::RakeTask.new(rg) do |t|
t.rspec_opts = %w(-fs --color)
Expand All @@ -69,7 +69,7 @@ begin

task "clone_rubygems_#{rg}" do
unless File.directory?("tmp/rubygems_#{rg}")
system("git clone git://github.com/jbarnette/rubygems.git tmp/rubygems_#{rg} && cd tmp/rubygems_#{rg} && git reset --hard #{rg}")
system("git clone git://github.com/rubygems/rubygems.git tmp/rubygems_#{rg} && cd tmp/rubygems_#{rg} && git reset --hard #{rg}")
end
ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems_#{rg}/lib")} #{rubyopt}"
end
Expand Down
2 changes: 1 addition & 1 deletion bundler.gemspec
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.name = "bundler"
s.version = Bundler::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Carl Lerche", "Yehuda Katz", "André Arko"]
s.authors = ["Carl Lerche", "Yehuda Katz", "André Arko", "Terence Lee"]
s.email = ["carlhuda@engineyard.com"]
s.homepage = "http://gembundler.com"
s.summary = %q{The best way to manage your application's dependencies}
Expand Down
8 changes: 5 additions & 3 deletions lib/bundler.rb
Expand Up @@ -95,16 +95,18 @@ def bin_path
end

def setup(*groups)
return @setup if defined?(@setup) && @setup
# Just return if all groups are already loaded
return @setup if defined?(@setup)

if groups.empty?
# Load all groups, but only once
@setup = load.setup
else
@completed_groups ||= []
# Figure out which groups haven't been loaded yet
unloaded = groups - (@completed_groups || [])
unloaded = groups - @completed_groups
# Record groups that are now loaded
@completed_groups = groups | (@completed_groups || [])
@completed_groups = groups
# Load any groups that are not yet loaded
unloaded.any? ? load.setup(*unloaded) : load
end
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/capistrano.rb
Expand Up @@ -7,4 +7,5 @@
Capistrano::Configuration.instance(:must_exist).load do
after "deploy:update_code", "bundle:install"
Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
set :rake, 'bundle exec rake'
end
12 changes: 7 additions & 5 deletions lib/bundler/cli.rb
Expand Up @@ -45,7 +45,7 @@ def help(cli = nil)

if have_groff? && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
groff = "groff -Wall -mtty-char -mandoc -Tascii"
pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more'
pager = ENV['MANPAGER'] || ENV['PAGER'] || 'less'

Kernel.exec "#{groff} #{root}/#{command} | #{pager}"
else
Expand Down Expand Up @@ -199,7 +199,7 @@ def install
Bundler.ui.be_quiet! if opts[:quiet]

Installer.install(Bundler.root, Bundler.definition, opts)
Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]

if Bundler.settings[:path]
relative_path = Bundler.settings[:path]
Expand Down Expand Up @@ -228,6 +228,8 @@ def install
possible versions of the gems in the bundle.
D
method_option "source", :type => :array, :banner => "Update a specific source (and all gems associated with it)"
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
def update(*gems)
sources = Array(options[:source])

Expand All @@ -238,7 +240,8 @@ def update(*gems)
Bundler.definition(:gems => gems, :sources => sources)
end

Installer.install Bundler.root, Bundler.definition, "update" => true
opts = {"update" => true, "local" => options[:local]}
Installer.install Bundler.root, Bundler.definition, opts
Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
Bundler.ui.confirm "Your bundle is updated! " +
"Use `bundle show [gemname]` to see where a bundled gem is installed."
Expand Down Expand Up @@ -390,8 +393,7 @@ def open(name)

desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil)
require 'bundler/setup'
group ? Bundler.require(:default, group) : Bundler.require
group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
ARGV.clear

require 'irb'
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/deployment.rb
@@ -1,15 +1,15 @@
module Bundler
class Deployment
def self.define_task(context, task_method = :task, opts = {})
if context.is_a?(Capistrano::Configuration)
if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
context_name = "capistrano"
role_default = "{:except => {:no_release => true}}"
else
context_name = "vlad"
role_default = "[:app]"
end

roles = context.fetch(:bundle_roles, nil)
roles = context.fetch(:bundle_roles, false)
opts[:roles] = roles if roles

context.send :namespace, :bundle do
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/dsl.rb
Expand Up @@ -29,7 +29,7 @@ def gemspec(opts = nil)

case gemspecs.size
when 1
spec = Gem::Specification.load(gemspecs.first)
spec = Bundler.load_gemspec(gemspecs.first)
raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec
gem spec.name, :path => path
group(development_group) do
Expand Down
13 changes: 6 additions & 7 deletions lib/bundler/gem_helper.rb
Expand Up @@ -4,9 +4,9 @@

module Bundler
class GemHelper
def self.install_tasks(opts = nil)
dir = File.dirname(Rake.application.rakefile_location)
self.new(dir, opts && opts[:name]).install
def self.install_tasks(opts = {})
dir = opts[:dir] || Dir.pwd
self.new(dir, opts[:name]).install
end

attr_reader :spec_path, :base, :gemspec
Expand Down Expand Up @@ -51,7 +51,7 @@ def build_gem

def install_gem
built_gem_path = build_gem
out, code = sh_with_code("gem install #{built_gem_path}")
out, _ = sh_with_code("gem install #{built_gem_path}")
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
Bundler.ui.confirm "#{name} (#{version}) installed"
end
Expand All @@ -68,7 +68,7 @@ def release_gem

protected
def rubygem_push(path)
out, status = sh("gem push #{path}")
out, _ = sh("gem push #{path}")
raise "Gem push failed due to lack of RubyGems.org credentials." if out[/Enter your RubyGems.org credentials/]
Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org"
end
Expand Down Expand Up @@ -100,8 +100,7 @@ def guard_clean
end

def clean?
out, code = sh_with_code("git diff --exit-code")
code == 0
sh_with_code("git diff --exit-code")[1] == 0
end

def tag_version
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/index.rb
Expand Up @@ -104,7 +104,7 @@ def search_by_spec(spec)
def same_version?(a, b)
regex = /^(.*?)(?:\.0)*$/

ret = a.to_s[regex, 1] == b.to_s[regex, 1]
a.to_s[regex, 1] == b.to_s[regex, 1]
end

def spec_satisfies_dependency?(spec, dep)
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/resolver.rb
Expand Up @@ -407,7 +407,7 @@ def gem_message(requirement)
end

def error_message
output = errors.inject("") do |o, (conflict, (origin, requirement))|
errors.inject("") do |o, (conflict, (origin, requirement))|

# origin is the SpecSet of specs from the Gemfile that is conflicted with
if origin
Expand All @@ -422,7 +422,7 @@ def error_message
o << " Current Bundler version:\n"
newer_bundler_required = requirement.requirement > Gem::Requirement.new(origin.version)
# If the origin is a LockfileParser, it does not respond_to :required_by
elsif !origin.respond_to?(:required_by) || !(required_by = origin.required_by.first)
elsif !origin.respond_to?(:required_by) || !(origin.required_by.first)
o << " In snapshot (Gemfile.lock):\n"
end

Expand Down
6 changes: 5 additions & 1 deletion lib/bundler/runtime.rb
Expand Up @@ -23,7 +23,11 @@ def setup(*groups)
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
"but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
e.name = spec.name
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
if e.respond_to?(:requirement=)
e.requirement = Gem::Requirement.new(spec.version.to_s)
else
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
end
raise e
end

Expand Down
13 changes: 11 additions & 2 deletions lib/bundler/shared_helpers.rb
Expand Up @@ -96,15 +96,24 @@ def cripple_rubygems(specs)
spec = specs.find { |s| s.name == dep.name }

if spec.nil?

e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
e.name = dep.name
e.version_requirement = dep.requirement
if e.respond_to?(:requirement=)
e.requirement = dep.requirement
else
e.version_requirement = dep.requirement
end
raise e
elsif dep !~ spec
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
"Make sure all dependencies are added to Gemfile."
e.name = dep.name
e.version_requirement = dep.requirement
if e.respond_to?(:requirement=)
e.requirement = dep.requirement
else
e.version_requirement = dep.requirement
end
raise e
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source.rb
Expand Up @@ -549,7 +549,7 @@ def git(command)
if allow_git_ops?
out = %x{git #{command}}

if $? != 0
if $?.exitstatus != 0
raise GitError, "An error has occurred in git when running `git #{command}`. Cannot complete bundling."
end
out
Expand Down
17 changes: 17 additions & 0 deletions spec/install/gems/groups_spec.rb
Expand Up @@ -43,6 +43,23 @@
out = run("require 'thin'; puts THIN")
out.should == '1.0'
end

it "removes old groups when new groups are set up" do
run <<-RUBY, :emo, :expect_err => true
Bundler.setup(:default)
require 'thin'; puts THIN
RUBY
@err.should =~ /no such file to load -- thin/i
end

it "sets up old groups when they have previously been removed" do
out = run <<-RUBY, :emo
Bundler.setup(:default)
Bundler.setup(:default, :emo)
require 'thin'; puts THIN
RUBY
out.should == '1.0'
end
end

describe "installing --without" do
Expand Down
12 changes: 12 additions & 0 deletions spec/install/gems/packed_spec.rb
Expand Up @@ -68,5 +68,17 @@
out.should == "1.0.0 RUBY"
end
end

it "does not update the cache if --no-cache is passed" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundled_app("vendor/cache").mkpath
bundled_app("vendor/cache").children.should be_empty

bundle "install --no-cache"
bundled_app("vendor/cache").children.should be_empty
end
end
end
2 changes: 1 addition & 1 deletion spec/install/gems/platform_spec.rb
Expand Up @@ -177,7 +177,7 @@
end

it "does not blow up on sources with all platform-excluded specs" do
git = build_git "foo"
build_git "foo"

install_gemfile <<-G
platform :#{not_local_tag} do
Expand Down
12 changes: 12 additions & 0 deletions spec/install/gemspec_spec.rb
Expand Up @@ -93,4 +93,16 @@
should_be_installed "bar-dev 1.0.0", :groups => :dev
end

it "should evaluate the gemspec in its directory" do
build_lib("foo", :path => tmp.join("foo"))
File.open(tmp.join("foo/foo.gemspec"), "w") do |s|
s.write "raise 'ahh' unless Dir.pwd == '#{tmp.join("foo")}'"
end

install_gemfile <<-G, :expect_err => true
gemspec :path => '#{tmp.join("foo")}'
G
@err.should_not match(/ahh/)
end

end
4 changes: 3 additions & 1 deletion spec/other/help_spec.rb
@@ -1,7 +1,9 @@
require "spec_helper"

describe "bundle help" do
it "complains if older versions of bundler are installed" do
# Rubygems 1.4+ no longer load gem plugins so this test is no longer needed
rubygems_under_14 = Gem::Requirement.new("< 1.4").satisfied_by?(Gem::Version.new(Gem::VERSION))
it "complains if older versions of bundler are installed", :if => rubygems_under_14 do
system_gems "bundler-0.8.1"

bundle "help", :expect_err => true
Expand Down
2 changes: 1 addition & 1 deletion spec/quality_spec.rb
Expand Up @@ -49,7 +49,7 @@ def check_for_extra_spaces(filename)
it "can still be built" do
Dir.chdir(root) do
`gem build bundler.gemspec`
$?.should == 0
check $?.should == 0

# clean up the .gem generated
system("rm bundler-#{Bundler::VERSION}.gem")
Expand Down

0 comments on commit 8161a70

Please sign in to comment.