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

Commit

Permalink
Merge v1.0.20.rc from branch '1-0-stable'
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGELOG.md
	lib/bundler/cli.rb
	lib/bundler/installer.rb
	lib/bundler/version.rb
  • Loading branch information
indirect committed Sep 19, 2011
2 parents 8497f4b + 3920fef commit ef4c631
Show file tree
Hide file tree
Showing 36 changed files with 369 additions and 166 deletions.
38 changes: 36 additions & 2 deletions CHANGELOG.md
@@ -1,3 +1,4 @@
<<<<<<< HEAD
## 1.1.pre.9

Bugfixes:
Expand Down Expand Up @@ -119,6 +120,39 @@ Removed:
- Removed bundle install --disable-shared-gems

## 1.0.18 (Aug 16, 2011)
=======
## 1.0.20.rc (September 18, 2011)

Features:

- Rescue interrupts to `bundle` while loading bundler.rb (#1395)
- Pass git directory paths instead of cd'ing (@tigris, #1213)
- Allow clearing without groups by passing `--without ''` (#1259)

Bugfixes:

- Manually sort requirements in the lockfile (#1375)
- Remove several warnings generated by ruby -w (@stephencelis)
- Handle trailing slashes on names passed to `gem` (#1372)
- Name modules for gems like 'test-foo_bar' correctly (#1303)
- Don't require Psych if Syck is already loaded (#1239)

## 1.0.19.rc (September 13, 2011)

Features:

- Compatability with Rubygems 1.8.10 installer changes
- Report gem installation failures clearly (@rwilcox, #1380)
- Useful error for cap and vlad on first deploy (@nexmat, @kirs)

Bugfixes:

- `exec` now works when the command contains 'exec'
- Only touch lock after changes on Windows (@robertwahler, #1358)
- Keep load paths when #setup is called multiple times (@radsaq, #1379)

## 1.0.18 (August 16, 2011)
>>>>>>> 1-0-stable
Bugfixes:

Expand All @@ -133,14 +167,14 @@ Features:
- Make fetch_specs faster (@zeha, #1294)
- Allow overriding development deps loaded by #gemspec (@lgierth, #1245)

## 1.0.17 (Aug 8, 2011)
## 1.0.17 (August 8, 2011)

Bugfixes:

- Fix rake issues with rubygems 1.3.x (#1342)
- Fixed invalid byte sequence error while installing gem on Ruby 1.9 (#1341)

## 1.0.16 (Aug 8, 2011)
## 1.0.16 (August 8, 2011)

Features:

Expand Down
4 changes: 2 additions & 2 deletions UPGRADING.md
Expand Up @@ -33,7 +33,7 @@ your deploy.rb file to run Bundler automatically as part of deploying:
require 'bundler/capistrano'

For more details on deploying using bundler, see the documentation
for the bundler cap task, and the [documentation on deploying](http://gembundler.com/v1.0/deploying.html).
for the bundler cap task, and the [documentation on deploying](http://gembundler.com/deploying.html).


## Bundler 0.8 to 0.9 and above
Expand Down Expand Up @@ -100,4 +100,4 @@ Bundler 0.9 changes the following Bundler 0.8 Gemfile APIs:
mode, where using system gems, this becomes
`Bundler.setup(:multiple, :groups)`. If you don't
specify any groups, this puts all groups on the load
path. In locked, mode, it becomes `require '.bundle/environment'`
path. In locked mode, it becomes `require '.bundle/environment'`
20 changes: 10 additions & 10 deletions bin/bundle
@@ -1,15 +1,15 @@
#!/usr/bin/env ruby

# Check if an older version of bundler is installed
require 'bundler'
$:.each do |path|
if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
abort "Please remove older versions of bundler. This can be done by running `gem cleanup bundler`."
end
end
require 'bundler/cli'

begin
require 'bundler'
# Check if an older version of bundler is installed
$:.each do |path|
if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
err = "Please remove Bundler 0.8 versions."
err << "This can be done by running `gem cleanup bundler`."
abort(err)
end
end
require 'bundler/cli'
Bundler::CLI.start
rescue Bundler::BundlerError => e
Bundler.ui.error e.message
Expand Down
3 changes: 2 additions & 1 deletion bundler.gemspec
Expand Up @@ -22,7 +22,8 @@ Gem::Specification.new do |s|

# Man files are required because they are ignored by git
man_files = Dir.glob("lib/bundler/man/**/*")
s.files = `git ls-files`.split("\n") + man_files
git_files = `git ls-files`.split("\n") rescue ''
s.files = git_files + man_files
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = %w(bundle)
s.require_paths = ["lib"]
Expand Down
9 changes: 5 additions & 4 deletions lib/bundler.rb
Expand Up @@ -3,7 +3,8 @@
require 'pathname'

begin
require 'psych'
# Pull in Psych if we can, but not if Syck is already loaded
require 'psych' unless defined?(YAML)
rescue LoadError
end

Expand Down Expand Up @@ -39,14 +40,15 @@ module Bundler
autoload :UI, 'bundler/ui'

class BundlerError < StandardError
def self.status_code(code = nil)
def self.status_code(code)
define_method(:status_code) { code }
end
end

class GemfileNotFound < BundlerError; status_code(10) ; end
class GemNotFound < BundlerError; status_code(7) ; end
class GemfileError < BundlerError; status_code(4) ; end
class InstallError < BundlerError; status_code(5) ; end
class PathError < BundlerError; status_code(13) ; end
class GitError < BundlerError; status_code(11) ; end
class DeprecatedError < BundlerError; status_code(12) ; end
Expand Down Expand Up @@ -115,8 +117,7 @@ def setup(*groups)
unloaded = groups - @completed_groups
# Record groups that are now loaded
@completed_groups = groups
# Load any groups that are not yet loaded
unloaded.any? ? load.setup(*unloaded) : load
unloaded.any? ? load.setup(*groups) : load
end
end

Expand Down
16 changes: 8 additions & 8 deletions lib/bundler/cli.rb
Expand Up @@ -158,12 +158,11 @@ def check
"Run bundle clean automatically after clean"
def install
opts = options.dup
opts[:without] ||= []
if opts[:without].size == 1
opts[:without] = opts[:without].map{|g| g.split(" ") }
if opts[:without]
opts[:without].map!{|g| g.split(" ") }
opts[:without].flatten!
opts[:without].map!{|g| g.to_sym }
end
opts[:without] = opts[:without].map{|g| g.to_sym }

# Can't use Bundler.settings for this because settings needs gemfile.dirname
ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
Expand Down Expand Up @@ -206,8 +205,8 @@ def install
Bundler.settings[:path] ||= "bundle" if opts[:standalone]
Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs]
Bundler.settings[:no_prune] = true if opts["no-prune"]
Bundler.settings[:disable_shared_gems] = '1' if Bundler.settings[:path]
Bundler.settings.without = opts[:without] unless opts[:without].empty?
Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil
Bundler.settings.without = opts[:without]
Bundler.ui.be_quiet! if opts[:quiet]

Bundler::Fetcher.disable_endpoint = opts["full-index"]
Expand Down Expand Up @@ -536,9 +535,10 @@ def viz
desc "gem GEM", "Creates a skeleton for creating a rubygem"
method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
def gem(name)
name = name.chomp("/") # remove trailing slash if present
target = File.join(Dir.pwd, name)
constant_name = name.split('_').map{|p| p.capitalize}.join
constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/
constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
constant_array = constant_name.split('::')
FileUtils.mkdir_p(File.join(target, 'lib', name))
git_user_name = `git config user.name`.chomp
Expand Down
8 changes: 4 additions & 4 deletions lib/bundler/definition.rb
Expand Up @@ -197,17 +197,17 @@ def groups
def lock(file)
contents = to_lock

# Convert to \r\n if the existing lock has them
# i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")

return if @lockfile_contents == contents

if Bundler.settings[:frozen]
# TODO: Warn here if we got here.
return
end

# Convert to \r\n if the existing lock has them
# i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")

File.open(file, 'wb'){|f| f.puts(contents) }
end

Expand Down
9 changes: 1 addition & 8 deletions lib/bundler/dependency.rb
Expand Up @@ -71,15 +71,8 @@ def current_platform?
end

def to_lock
out = " #{name}"

unless requirement == Gem::Requirement.default
reqs = requirement.requirements.map{|o,v| "#{o} #{v}" }
out << " (#{reqs.join(', ')})"
end

out = super
out << '!' if source

out << "\n"
end

Expand Down
11 changes: 8 additions & 3 deletions lib/bundler/deployment.rb
Expand Up @@ -4,9 +4,11 @@ def self.define_task(context, task_method = :task, opts = {})
if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
context_name = "capistrano"
role_default = "{:except => {:no_release => true}}"
error_type = ::Capistrano::CommandError
else
context_name = "vlad"
role_default = "[:app]"
error_type = ::Rake::CommandFailedError
end

roles = context.fetch(:bundle_roles, false)
Expand Down Expand Up @@ -39,13 +41,16 @@ def self.define_task(context, task_method = :task, opts = {})
bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), 'bundle'))
bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact

args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
current_release = context.fetch(:current_release)
if current_release.to_s.empty?
raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
end
args = ["--gemfile #{File.join(current_release, bundle_gemfile)}"]
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
args << bundle_flags.to_s
args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?

run "cd #{context.fetch(:current_release)} && #{bundle_cmd} install #{args.join(' ')}"
run "cd #{current_release} && #{bundle_cmd} install #{args.join(' ')}"
end
end
end
Expand Down
41 changes: 26 additions & 15 deletions lib/bundler/installer.rb
Expand Up @@ -53,21 +53,7 @@ def run(options)
# the gem.
Installer.post_install_messages = {}
specs.each do |spec|
Bundler::Fetcher.fetch(spec) if spec.source.is_a?(Bundler::Source::Rubygems)

# unless requested_specs.include?(spec)
# Bundler.ui.debug " * Not in requested group; skipping."
# next
# end

Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do
spec.source.install(spec)
Bundler.ui.debug "from #{spec.loaded_from} "
end

Bundler.ui.info ""
generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
FileUtils.rm_rf(Bundler.tmp)
install_gem_from_spec(spec)
end

lock
Expand All @@ -76,6 +62,31 @@ def run(options)

private

def install_gem_from_spec(spec)
# Download the gem to get the spec, because some specs that are returned
# by rubygems.org are broken and wrong.
Bundler::Fetcher.fetch(spec) if spec.source.is_a?(Bundler::Source::Rubygems)

# Fetch the build settings, if there are any
settings = Bundler.settings["build.#{spec.name}"]
Bundler.rubygems.with_build_args [settings] do
spec.source.install(spec)
Bundler.ui.debug "from #{spec.loaded_from} "
end

# newline comes after installing, some gems say "with native extensions"
Bundler.ui.info ""
generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
FileUtils.rm_rf(Bundler.tmp)
rescue Exception => e
Bundler.ui.info ""
Bundler.ui.warn "#{e.class}: #{e.message}"
msg = "An error occured while installing #{spec.name} (#{spec.version}),"
msg << " and Bundler cannot continue.\nMake sure that `gem install"
msg << " #{spec.name} -v '#{spec.version}'` succeeds before bundling."
raise Bundler::InstallError, msg
end

def generate_bundler_executable_stubs(spec)
bin_path = Bundler.bin_path
template = File.read(File.expand_path('../templates/Executable', __FILE__))
Expand Down
4 changes: 3 additions & 1 deletion lib/bundler/rubygems_ext.rb
Expand Up @@ -40,6 +40,7 @@ def load_paths
end

# RubyGems 1.8+ used only.
remove_method :gem_dir if method_defined? :gem_dir
def gem_dir
full_gem_path
end
Expand Down Expand Up @@ -107,7 +108,7 @@ def to_yaml_properties
def to_lock
out = " #{name}"
unless requirement == Gem::Requirement.default
reqs = requirement.requirements.map{|o,v| "#{o} #{v}" }
reqs = requirement.requirements.map{|o,v| "#{o} #{v}" }.sort.reverse
out << " (#{reqs.join(', ')})"
end
out
Expand Down Expand Up @@ -135,6 +136,7 @@ class Platform
MSWIN = Gem::Platform.new('mswin32')
MINGW = Gem::Platform.new('x86-mingw32')

undef_method :hash if method_defined? :hash
def hash
@cpu.hash ^ @os.hash ^ @version.hash
end
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/rubygems_integration.rb
Expand Up @@ -185,6 +185,7 @@ def stub_source_index137(specs)
end

def stub_source_index170(specs)
Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
Gem::SourceIndex.send(:define_method, :initialize) do |*args|
@gems = {}
# You're looking at this thinking: Oh! This is how I make those
Expand Down
5 changes: 2 additions & 3 deletions lib/bundler/settings.rb
Expand Up @@ -62,9 +62,7 @@ def pretty_values_for(exposed_key)
end

def without=(array)
unless array.empty?
self[:without] = array.join(":")
end
self[:without] = (array.empty? ? nil : array.join(":")) if array
end

def without
Expand Down Expand Up @@ -95,6 +93,7 @@ def key_for(key)

def set_key(key, value, hash, file)
key = key_for(key)
puts key.inspect

unless hash[key] == value
hash[key] = value
Expand Down

0 comments on commit ef4c631

Please sign in to comment.