diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/bundler.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/outdated.rb | 8 | ||||
-rw-r--r-- | lib/bundler/cli/show.rb | 2 | ||||
-rw-r--r-- | lib/bundler/dsl.rb | 16 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 8 | ||||
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 9 | ||||
-rw-r--r-- | lib/bundler/source.rb | 1 | ||||
-rw-r--r-- | lib/bundler/source/svn.rb | 259 | ||||
-rw-r--r-- | lib/bundler/source/svn/svn_proxy.rb | 110 | ||||
-rw-r--r-- | lib/bundler/source_list.rb | 15 | ||||
-rw-r--r-- | spec/bundler/source_list_spec.rb | 79 | ||||
-rw-r--r-- | spec/cache/gems_spec.rb | 32 | ||||
-rw-r--r-- | spec/cache/svn_spec.rb | 82 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 15 | ||||
-rw-r--r-- | spec/commands/clean_spec.rb | 36 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 46 | ||||
-rw-r--r-- | spec/commands/show_spec.rb | 16 | ||||
-rw-r--r-- | spec/install/deploy_spec.rb | 12 | ||||
-rw-r--r-- | spec/install/gemfile/svn_spec.rb | 582 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 28 | ||||
-rw-r--r-- | spec/lock/svn_spec.rb | 35 | ||||
-rw-r--r-- | spec/support/builders.rb | 67 | ||||
-rw-r--r-- | spec/update/svn_spec.rb | 100 |
25 files changed, 19 insertions, 1550 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f1a0b75..06fcfa1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ Features: - - add support for SVN sources (@msnexploder) - add metadata allowed_push_host to new gem template (#3002, @juanitofatas) - adds a `--no-install` flag to `bundle package` - add `bundle viz --without` to exclude gem groups from resulting graph (@fnichol) diff --git a/lib/bundler.rb b/lib/bundler.rb index 40cd8aad..2b2c9d75 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -61,7 +61,6 @@ module Bundler class InstallHookError < BundlerError; status_code(8) ; end class PathError < BundlerError; status_code(13) ; end class GitError < BundlerError; status_code(11) ; end - class SVNError < BundlerError; status_code(23) ; end class DeprecatedError < BundlerError; status_code(12) ; end class GemspecError < BundlerError; status_code(14) ; end class InvalidOption < BundlerError; status_code(15) ; end @@ -382,11 +381,6 @@ module Bundler @git_present = Bundler.which("git") || Bundler.which("git.exe") end - def svn_present? - return @svn_present if defined?(@svn_present) - @svn_present = Bundler.which("svn") || Bundler.which("svn.exe") - end - def ruby_version @ruby_version ||= SystemRubyVersion.new end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 9f084a41..6a220725 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -228,7 +228,7 @@ module Bundler end desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true - method_option "all", :type => :boolean, :banner => "Include all sources (including path, git and svn)." + method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms, not just the current one" method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." def cache @@ -237,7 +237,7 @@ module Bundler end desc "package [OPTIONS]", "Locks and then caches all of the gems into vendor/cache" - method_option "all", :type => :boolean, :banner => "Include all sources (including path, git and svn)." + method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms, not just the current one" method_option "cache-path", :type => :string, :banner => "Specify a different cache path than the default (vendor/cache)." diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index c6e0f6ba..f8779d76 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -50,8 +50,8 @@ module Bundler next if active_spec.nil? gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version) - scm_outdated = current_spec.scm_version != active_spec.scm_version - if gem_outdated || scm_outdated + git_outdated = current_spec.git_version != active_spec.git_version + if gem_outdated || git_outdated if out_count == 0 if options["pre"] Bundler.ui.info "Outdated gems included in the bundle (including pre-releases):" @@ -60,8 +60,8 @@ module Bundler end end - spec_version = "#{active_spec.version}#{active_spec.scm_version}" - current_version = "#{current_spec.version}#{current_spec.scm_version}" + spec_version = "#{active_spec.version}#{active_spec.git_version}" + current_version = "#{current_spec.version}#{current_spec.git_version}" dependency_version = %|Gemfile specifies "#{dependency.requirement}"| if dependency && dependency.specific? Bundler.ui.info " * #{active_spec.name} (#{spec_version} > #{current_version}) #{dependency_version}".rstrip out_count += 1 diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb index 6a27265a..96c14902 100644 --- a/lib/bundler/cli/show.rb +++ b/lib/bundler/cli/show.rb @@ -37,7 +37,7 @@ module Bundler else Bundler.ui.info "Gems included by the bundle:" Bundler.load.specs.sort_by { |s| s.name }.each do |s| - desc = " * #{s.name} (#{s.version}#{s.scm_version})" + desc = " * #{s.name} (#{s.version}#{s.git_version})" if @verbose latest = latest_specs.find { |l| l.name == s.name } Bundler.ui.info <<-END.gsub(/^ +/, '') diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index c4e59f30..e2853e08 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -152,18 +152,6 @@ module Bundler with_source(@sources.add_git_source(normalize_hash(options).merge("github" => repo)), &blk) end - def svn(uri, options = {}, source_options = {}, &blk) - unless block_given? - msg = "You can no longer specify a svn source by itself. Instead, \n" \ - "either use the :svn option on a gem, or specify the gems that \n" \ - "bundler should find in the svn source by passing a block to \n" \ - "the svn method." - raise DeprecatedError, msg - end - - with_source(@sources.add_svn_source(normalize_hash(options).merge("uri" => uri)), &blk) - end - def to_definition(lockfile, unlock) Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version) end @@ -231,7 +219,7 @@ module Bundler end def valid_keys - @valid_keys ||= %w(group groups git svn path name branch ref tag require submodules platform platforms type source) + @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type source) end def normalize_options(name, version, opts) @@ -284,7 +272,7 @@ module Bundler opts["git"] = @git_sources[git_name].call(opts[git_name]) end - ["git", "path", "svn"].each do |type| + ["git", "path"].each do |type| if param = opts[type] if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ options = opts.merge("name" => name, "version" => $1) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 0254a0cf..7c7357a1 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -19,7 +19,6 @@ module Bundler GIT = "GIT" GEM = "GEM" PATH = "PATH" - SVN = "SVN" SPECS = " specs:" OPTIONS = /^ ([a-z]+): (.*)$/i @@ -56,12 +55,11 @@ module Bundler GIT => Bundler::Source::Git, GEM => Bundler::Source::Rubygems, PATH => Bundler::Source::Path, - SVN => Bundler::Source::SVN } def parse_source(line) case line - when GIT, GEM, PATH, SVN + when GIT, GEM, PATH @current_source = nil @opts, @type = {}, line when SPECS @@ -69,9 +67,9 @@ module Bundler when PATH @current_source = TYPES[@type].from_lock(@opts) @sources << @current_source - when GIT, SVN + when GIT @current_source = TYPES[@type].from_lock(@opts) - # Strip out duplicate GIT / SVN sections + # Strip out duplicate GIT sections if @sources.include?(@current_source) @current_source = @sources.find { |s| s == @current_source } else diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 5d717741..55f2139a 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -66,12 +66,9 @@ module Gem @groups ||= [] end - def scm_version - return unless loaded_from - case source - when Bundler::Source::Git then " #{source.revision[0..6]}" - when Bundler::Source::SVN then " #{source.revision}" - end + def git_version + return unless loaded_from && source.is_a?(Bundler::Source::Git) + " #{source.revision[0..6]}" end def to_gemfile(path = nil) diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 2e3485ce..d1fd35a3 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -3,7 +3,6 @@ module Bundler autoload :Rubygems, 'bundler/source/rubygems' autoload :Path, 'bundler/source/path' autoload :Git, 'bundler/source/git' - autoload :SVN, 'bundler/source/svn' def self.mirror_for(uri) uri = URI(uri.to_s) unless uri.is_a?(URI) diff --git a/lib/bundler/source/svn.rb b/lib/bundler/source/svn.rb deleted file mode 100644 index a7a42ecf..00000000 --- a/lib/bundler/source/svn.rb +++ /dev/null @@ -1,259 +0,0 @@ -require 'fileutils' -require 'uri' -require 'digest/sha1' - -module Bundler - class Source - - class SVN < Path - autoload :SVNProxy, 'bundler/source/svn/svn_proxy' - - attr_reader :uri, :ref, :options - - def initialize(options) - @options = options - @glob = options["glob"] || DEFAULT_GLOB - - @allow_cached = false - @allow_remote = false - - # Stringify options that could be set as symbols - %w(ref revision).each{|k| options[k] = options[k].to_s if options[k] } - - @uri = options["uri"] - @ref = options["ref"] || 'HEAD' - @name = options["name"] - @version = options["version"] - - @copied = false - @local = false - end - - def self.from_lock(options) - new(options.merge("uri" => options.delete("remote"))) - end - - def to_lock - out = "SVN\n" - out << " remote: #{@uri}\n" - out << " revision: #{revision}\n" - out << " ref: #{ref}\n" - out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB - out << " specs:\n" - end - - def hash - [self.class, uri, ref, name, version].hash - end - - def eql?(o) - o.is_a?(SVN) && - uri == o.uri && - ref == o.ref && - name == o.name && - version == o.version - end - - alias == eql? - - def to_s - at = if local? - path - elsif options["ref"] - options["ref"] - else - ref - end - "#{uri} (at #{at})" - end - - def name - File.basename(@uri, '.svn') - end - - # This is the path which is going to contain a specific - # checkout of the svn repository. When using local svn - # repos, this is set to the local repo. - def install_path - @install_path ||= begin - svn_scope = "#{base_name}-#{revision}" - - if Bundler.requires_sudo? - Bundler.user_bundle_path.join(Bundler.ruby_scope).join(svn_scope) - else - Bundler.install_path.join(svn_scope) - end - end - end - - alias :path :install_path - - def extension_dir_name - "#{base_name}-#{revision}" - end - - def unlock! - svn_proxy.revision = nil - @unlocked = true - end - - def local_override!(path) - return false if local? - - path = Pathname.new(path) - path = path.expand_path(Bundler.root) unless path.relative? - - unless path.exist? - raise SVNError, "Cannot use local override for #{name} because #{path} " \ - "does not exist. Check `bundle config --delete` to remove the local override" - end - - set_local!(path) - - # Create a new svn proxy without the cached revision - # so the Gemfile.lock always picks up the new revision. - @svn_proxy = SVNProxy.new(path, uri, ref) - true - end - - # TODO: actually cache svn specs - def specs(*) - if has_app_cache? && !local? - set_local!(app_cache_path) - end - - if requires_checkout? && !@copied - svn_proxy.checkout - svn_proxy.copy_to(install_path) - serialize_gemspecs_in(install_path) - @copied = true - end - - local_specs - end - - def install(spec) - debug = nil - if requires_checkout? && !@copied - debug = " * Checking out revision: #{ref}" - svn_proxy.copy_to(install_path) - serialize_gemspecs_in(install_path) - @copied = true - end - generate_bin(spec) - if requires_checkout? && spec.post_install_message - Installer.post_install_messages[spec.name] = spec.post_install_message - end - ["Using #{version_message(spec)} from #{to_s}", nil, debug] - end - - def cache(spec, custom_path = nil) - app_cache_path = app_cache_path(custom_path) - return unless Bundler.settings[:cache_all] - return if path == app_cache_path - cached! - FileUtils.rm_rf(app_cache_path) - svn_proxy.checkout if requires_checkout? - svn_proxy.copy_to(app_cache_path) - serialize_gemspecs_in(app_cache_path) - end - - def load_spec_files - super - rescue PathError => e - Bundler.ui.trace e - raise SVNError, "#{to_s} is not yet checked out. Run `bundle install` first." - end - - # This is the path which is going to contain a cache - # of the svn repository. When using the same svn repository - # across different projects, this cache will be shared. - # When using local svn repos, this is set to the local repo. - def cache_path - @cache_path ||= begin - svn_scope = "#{base_name}-#{uri_hash}" - - if Bundler.requires_sudo? - Bundler.user_bundle_path.join("cache/svn", svn_scope) - else - Bundler.cache.join("svn", svn_scope) - end - end - end - - def app_cache_dirname - "#{base_name}-#{(cached_revision || revision)}" - end - - def revision - svn_proxy.revision - end - - def allow_svn_ops? - @allow_remote || @allow_cached - end - - private - - def serialize_gemspecs_in(destination) - expanded_path = destination.expand_path(Bundler.root) - Dir["#{expanded_path}/#{@glob}"].each do |spec_path| - # Evaluate gemspecs and cache the result. Gemspecs - # in svn might require svn or other dependencies. - # The gemspecs we cache should already be evaluated. - spec = Bundler.load_gemspec(spec_path) - next unless spec - File.open(spec_path, 'wb') {|file| file.write(spec.to_ruby) } - end - end - - def set_local!(path) - @local = true - @local_specs = @svn_proxy = nil - @cache_path = @install_path = path - end - - def has_app_cache? - cached_revision && super - end - - def local? - @local - end - - def requires_checkout? - allow_svn_ops? && !local? - end - - def base_name - File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)?(//\w*/)?(\w*/)*},''),".svn") - end - - def uri_hash - if uri =~ %r{^\w+://(\w+@)?} - # Downcase the domain component of the URI - # and strip off a trailing slash, if one is present - input = URI.parse(uri).normalize.to_s.sub(%r{/$},'') - else - # If there is no URI scheme, assume it is an ssh/svn URI - input = uri - end - Digest::SHA1.hexdigest(input) - end - - def cached_revision - options["revision"] - end - - def cached? - cache_path.exist? - end - - def svn_proxy - @svn_proxy ||= SVNProxy.new(cache_path, uri, ref, cached_revision, self) - end - - end - - end -end diff --git a/lib/bundler/source/svn/svn_proxy.rb b/lib/bundler/source/svn/svn_proxy.rb deleted file mode 100644 index c67a9372..00000000 --- a/lib/bundler/source/svn/svn_proxy.rb +++ /dev/null @@ -1,110 +0,0 @@ -module Bundler - class Source - class SVN < Path - - class SVNNotInstalledError < SVNError - def initialize - msg = "You need to install svn to be able to use gems from svn repositories. " - msg << "For help installing svn, please refer to SVNook's tutorial at http://svnbook.red-bean.com/en/1.7/svn.intro.install.html" - super msg - end - end - - class SVNNotAllowedError < SVNError - def initialize(command) - msg = "Bundler is trying to run a `svn #{command}` at runtime. You probably need to run `bundle install`. However, " - msg << "this error message could probably be more useful. Please submit a ticket at http://github.com/bundler/bundler/issues " - msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}" - super msg - end - end - - class SVNCommandError < SVNError - def initialize(command, path = nil) - msg = "SVN error: command `svn #{command}` in directory #{Dir.pwd} has failed." - msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path && path.exist? - super msg - end - end - - # The SVNProxy is responsible to interact with svn repositories. - # All actions required by the SVN source is encapsulated in this - # object. - class SVNProxy - attr_accessor :path, :uri, :ref - attr_writer :revision - - def initialize(path, uri, ref, revision = nil, svn = nil) - @path = path - @uri = uri - @ref = ref - @revision = revision - @svn = svn - raise SVNNotInstalledError.new if allow? && !Bundler.svn_present? - end - - def revision - @revision ||= svn("info --revision #{ref} #{uri_escaped} | grep \"Revision\" | awk '{print $2}'").strip - end - - def checkout - if path.exist? - Bundler.ui.confirm "Updating #{uri}" - in_path do - svn_retry %|update --force --quiet --revision #{revision}| - end - else - Bundler.ui.info "Fetching #{uri}" - FileUtils.mkdir_p(path.dirname) - svn_retry %|checkout --revision #{revision} #{uri_escaped} "#{path}"| - end - end - - def copy_to(destination) - FileUtils.mkdir_p(destination.dirname) - FileUtils.rm_rf(destination) - FileUtils.cp_r(path, destination) - File.chmod((0777 & ~File.umask), destination) - end - - private - - def svn_retry(command) - Bundler::Retry.new("svn #{command}", SVNNotAllowedError).attempts do - svn(command) - end - end - - def svn(command, check_errors=true) - raise SVNNotAllowedError.new(command) unless allow? - out = %x{svn #{command}} - raise SVNCommandError.new(command, path) if check_errors && !$?.success? - out - end - - # Escape the URI for svn commands - def uri_escaped - if Bundler::WINDOWS - # Windows quoting requires double quotes only, with double quotes - # inside the string escaped by being doubled. - '"' + uri.gsub('"') {|s| '""'} + '"' - else - # Bash requires single quoted strings, with the single quotes escaped - # by ending the string, escaping the quote, and restarting the string. - "'" + uri.gsub("'") {|s| "'\\''"} + "'" - end - end - - def allow? - @svn ? @svn.allow_svn_ops? : true - end - - def in_path(&blk) - checkout unless path.exist? - SharedHelpers.chdir(path, &blk) - end - end - - end - end -end diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index 3ca6d4ad..49a976ba 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -1,13 +1,11 @@ module Bundler class SourceList attr_reader :path_sources, - :git_sources, - :svn_sources + :git_sources def initialize @path_sources = [] @git_sources = [] - @svn_sources = [] @rubygems_aggregate = Source::Rubygems.new @rubygems_sources = [] end @@ -20,10 +18,6 @@ module Bundler add_source_to_list Source::Git.new(options), git_sources end - def add_svn_source(options = {}) - add_source_to_list Source::SVN.new(options), svn_sources - end - def add_rubygems_source(options = {}) add_source_to_list Source::Rubygems.new(options), @rubygems_sources end @@ -42,7 +36,7 @@ module Bundler end def all_sources - path_sources + git_sources + svn_sources + rubygems_sources + path_sources + git_sources + rubygems_sources end def get(source) @@ -50,14 +44,14 @@ module Bundler end def lock_sources - lock_sources = (path_sources + git_sources + svn_sources).sort_by(&:to_s) + lock_sources = (path_sources + git_sources).sort_by(&:to_s) lock_sources << combine_rubygems_sources end def replace_sources!(replacement_sources) return true if replacement_sources.empty? - [path_sources, git_sources, svn_sources].each do |source_list| + [path_sources, git_sources].each do |source_list| source_list.map! do |source| replacement_sources.find { |s| s == source } || source end @@ -90,7 +84,6 @@ module Bundler def source_list_for(source) case source when Source::Git then git_sources - when Source::SVN then svn_sources when Source::Path then path_sources when Source::Rubygems then rubygems_sources else raise ArgumentError, "Invalid source: #{source.inspect}" diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 7c422d3d..f5a8575a 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -62,29 +62,6 @@ describe Bundler::SourceList do end end - describe "#add_svn_source" do - before do - @duplicate = source_list.add_svn_source('uri' => 'svn://host/path') - @new_source = source_list.add_svn_source('uri' => 'svn://host/path') - end - - it "returns the new svn source" do - expect(@new_source).to be_instance_of(Bundler::Source::SVN) - end - - it "passes the provided options to the new source" do - expect(@new_source.options).to eq('uri' => 'svn://host/path') - end - - it "adds the source to the beginning of svn_sources" do - expect(source_list.svn_sources.first).to equal(@new_source) - end - - it "removes existing duplicates" do - expect(source_list.svn_sources).not_to include equal(@duplicate) - end - end - describe "#add_rubygems_source" do before do @duplicate = source_list.add_rubygems_source('remotes' => ['https://rubygems.org/']) @@ -140,23 +117,7 @@ describe Bundler::SourceList do expect(source_list.all_sources).to include rubygems_aggregate end - it "returns path sources before git sources before svn sources before rubygems sources before the aggregate" do - source_list.add_git_source('uri' => 'git://host/path.git') - source_list.add_rubygems_source('remotes' => ['https://rubygems.org']) - source_list.add_path_source('path' => '/path/to/gem') - source_list.add_svn_source('uri' => 'svn://host/path') - - expect(source_list.all_sources).to eq [ - Bundler::Source::Path.new('path' => '/path/to/gem'), - Bundler::Source::Git.new('uri' => 'git://host/path.git'), - Bundler::Source::SVN.new('uri' => 'svn://host/path'), - Bundler::Source::Rubygems.new('remotes' => ['https://rubygems.org']), - rubygems_aggregate, - ] - end - it "returns sources of the same type in the reverse order that they were added" do - source_list.add_svn_source('uri' => 'svn://second-svn.org/path') source_list.add_git_source('uri' => 'git://third-git.org/path.git') source_list.add_rubygems_source('remotes' => ['https://fifth-rubygems.org']) source_list.add_path_source('path' => '/third/path/to/gem') @@ -168,7 +129,6 @@ describe Bundler::SourceList do source_list.add_path_source('path' => '/first/path/to/gem') source_list.add_rubygems_source('remotes' => ['https://first-rubygems.org']) source_list.add_git_source('uri' => 'git://first-git.org/path.git') - source_list.add_svn_source('uri' => 'svn://first-svn.org/path') expect(source_list.all_sources).to eq [ Bundler::Source::Path.new('path' => '/first/path/to/gem'), @@ -177,8 +137,6 @@ describe Bundler::SourceList do Bundler::Source::Git.new('uri' => 'git://first-git.org/path.git'), Bundler::Source::Git.new('uri' => 'git://second-git.org/path.git'), Bundler::Source::Git.new('uri' => 'git://third-git.org/path.git'), - Bundler::Source::SVN.new('uri' => 'svn://first-svn.org/path'), - Bundler::Source::SVN.new('uri' => 'svn://second-svn.org/path'), Bundler::Source::Rubygems.new('remotes' => ['https://first-rubygems.org']), Bundler::Source::Rubygems.new('remotes' => ['https://second-rubygems.org']), Bundler::Source::Rubygems.new('remotes' => ['https://third-rubygems.org']), @@ -246,35 +204,6 @@ describe Bundler::SourceList do end end - describe "#svn_sources" do - it "returns an empty array when no svn sources have been added" do - source_list.add_rubygems_remote('https://rubygems.org') - source_list.add_path_source('path' => '/path/to/gem') - - expect(source_list.svn_sources).to be_empty - end - - it "returns svn sources in the reverse order that they were added" do - source_list.add_svn_source('uri' => 'svn://third-svn.org/path') - source_list.add_rubygems_remote('https://fifth-rubygems.org') - source_list.add_path_source('path' => '/third/path/to/gem') - source_list.add_rubygems_remote('https://fourth-rubygems.org') - source_list.add_path_source('path' => '/second/path/to/gem') - source_list.add_rubygems_remote('https://third-rubygems.org') - source_list.add_svn_source('uri' => 'svn://second-svn.org/path') - source_list.add_rubygems_remote('https://second-rubygems.org') - source_list.add_path_source('path' => '/first/path/to/gem') - source_list.add_rubygems_remote('https://first-rubygems.org') - source_list.add_svn_source('uri' => 'svn://first-svn.org/path') - - expect(source_list.svn_sources).to eq [ - Bundler::Source::SVN.new('uri' => 'svn://first-svn.org/path'), - Bundler::Source::SVN.new('uri' => 'svn://second-svn.org/path'), - Bundler::Source::SVN.new('uri' => 'svn://third-svn.org/path'), - ] - end - end - describe "#rubygems_sources" do it "includes the aggregate rubygems source when rubygems sources have been added" do source_list.add_git_source('uri' => 'git://host/path.git') @@ -336,7 +265,6 @@ describe Bundler::SourceList do describe "#lock_sources" do it "combines the rubygems sources into a single instance, removing duplicate remotes from the end" do - source_list.add_svn_source('uri' => 'svn://second-svn.org/path') source_list.add_git_source('uri' => 'git://third-git.org/path.git') source_list.add_rubygems_source('remotes' => ['https://duplicate-rubygems.org']) source_list.add_path_source('path' => '/third/path/to/gem') @@ -348,7 +276,6 @@ describe Bundler::SourceList do source_list.add_path_source('path' => '/first/path/to/gem') source_list.add_rubygems_source('remotes' => ['https://duplicate-rubygems.org']) source_list.add_git_source('uri' => 'git://first-git.org/path.git') - source_list.add_svn_source('uri' => 'svn://first-svn.org/path') expect(source_list.lock_sources).to eq [ Bundler::Source::Git.new('uri' => 'git://first-git.org/path.git'), @@ -357,8 +284,6 @@ describe Bundler::SourceList do Bundler::Source::Path.new('path' => '/first/path/to/gem'), Bundler::Source::Path.new('path' => '/second/path/to/gem'), Bundler::Source::Path.new('path' => '/third/path/to/gem'), - Bundler::Source::SVN.new('uri' => 'svn://first-svn.org/path'), - Bundler::Source::SVN.new('uri' => 'svn://second-svn.org/path'), Bundler::Source::Rubygems.new('remotes' => [ 'https://duplicate-rubygems.org', 'https://first-rubygems.org', @@ -397,13 +322,11 @@ describe Bundler::SourceList do describe "#cached!" do let(:rubygems_source) { source_list.add_rubygems_remote('https://rubygems.org') } let(:git_source) { source_list.add_git_source('uri' => 'git://host/path.git') } - let(:svn_source) { source_list.add_svn_source('uri' => 'svn://host/path') } let(:path_source) { source_list.add_path_source('path' => '/path/to/gem') } it "calls #cached! on all the sources" do expect(rubygems_source).to receive(:cached!) expect(git_source).to receive(:cached!) - expect(svn_source).to receive(:cached!) expect(path_source).to receive(:cached!) source_list.cached! end @@ -412,13 +335,11 @@ describe Bundler::SourceList do describe "#remote!" do let(:rubygems_source) { source_list.add_rubygems_remote('https://rubygems.org') } let(:git_source) { source_list.add_git_source('uri' => 'git://host/path.git') } - let(:svn_source) { source_list.add_git_source('uri' => 'svn://host/path') } let(:path_source) { source_list.add_path_source('path' => '/path/to/gem') } it "calls #remote! on all the sources" do expect(rubygems_source).to receive(:remote!) expect(git_source).to receive(:remote!) - expect(svn_source).to receive(:remote!) expect(path_source).to receive(:remote!) source_list.remote! end diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb index 9386164c..b70f6274 100644 --- a/spec/cache/gems_spec.rb +++ b/spec/cache/gems_spec.rb @@ -151,38 +151,6 @@ describe "bundle cache" do end end - describe "when there are also svn sources" do - before do - build_svn "foo" - system_gems "rack-1.0.0" - - install_gemfile <<-G - source "file://#{gem_repo1}" - svn "file://#{lib_path("foo-1.0")}" do - gem 'foo' - end - gem 'rack' - G - end - - it "still works" do - bundle :cache - - system_gems [] - bundle "install --local" - - should_be_installed("rack 1.0.0", "foo 1.0") - end - - it "should not explode if the lockfile is not present" do - FileUtils.rm(bundled_app("Gemfile.lock")) - - bundle :cache - - expect(bundled_app("Gemfile.lock")).to exist - end - end - describe "when previously cached" do before :each do build_repo2 diff --git a/spec/cache/svn_spec.rb b/spec/cache/svn_spec.rb deleted file mode 100644 index e798e0e9..00000000 --- a/spec/cache/svn_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require "spec_helper" - -%w(cache package).each do |cmd| - describe "bundle #{cmd} with svn" do - it "copies repository to vendor cache and uses it" do - svn = build_svn "foo" - ref = svn.ref_for("HEAD") - - install_gemfile <<-G - gem "foo", :svn => 'file://#{lib_path("foo-1.0")}' - G - - bundle "#{cmd} --all" - expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist - expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.svn")).to exist - - FileUtils.rm_rf lib_path("foo-1.0") - should_be_installed "foo 1.0" - end - - it "copies repository to vendor cache and uses it even when installed with bundle --path" do - svn = build_svn "foo" - ref = svn.ref_for("HEAD") - - install_gemfile <<-G - gem "foo", :svn => 'file://#{lib_path("foo-1.0")}' - G - - bundle "install --path vendor/bundle" - bundle "#{cmd} --all" - - expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist - expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.svn")).to exist - - FileUtils.rm_rf lib_path("foo-1.0") - should_be_installed "foo 1.0" - end - - it "runs twice without exploding" do - build_svn "foo" - - install_gemfile <<-G - gem "foo", :svn => 'file://#{lib_path("foo-1.0")}' - G - - bundle "#{cmd} --all" - bundle "#{cmd} --all" - - expect(err).to eq("") - FileUtils.rm_rf lib_path("foo-1.0") - should_be_installed "foo 1.0" - end - - it "tracks updates" do - svn = build_svn "foo" - old_ref = svn.ref_for("HEAD") - - install_gemfile <<-G - gem "foo", :svn => 'file://#{lib_path("foo-1.0")}' - G - - bundle "#{cmd} --all" - - update_svn "foo" do |s| - s.write "lib/foo.rb", "puts :CACHE" - end - - ref = svn.ref_for("HEAD") - expect(ref).not_to eq(old_ref) - - bundle "update" - bundle "#{cmd} --all" - - expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist - - FileUtils.rm_rf lib_path("foo-1.0") - run "require 'foo'" - expect(out).to eq("CACHE") - end - - end -end diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 947b0bee..284913a3 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -61,21 +61,6 @@ describe "bundle binstubs <gem>" do expect(out).to eq("Sorry, Bundler can only be run via Rubygems.") end - it "installs binstubs from svn gems" do - FileUtils.mkdir_p(lib_path("foo/bin")) - FileUtils.touch(lib_path("foo/bin/foo")) - build_svn "foo", "1.0", :path => lib_path("foo") do |s| - s.executables = %w(foo) - end - install_gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo')}" - G - - bundle "binstubs foo" - - expect(bundled_app("bin/foo")).to exist - end - it "installs binstubs from git gems" do FileUtils.mkdir_p(lib_path("foo/bin")) FileUtils.touch(lib_path("foo/bin/foo")) diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index a9f65745..529c2459 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -145,42 +145,6 @@ describe "bundle clean" do expect(vendored_gems("cache/bundler/git/foo-1.0-#{digest}")).to exist end - it "removes unused svn gems" do - build_svn "foo", :path => lib_path("foo") - svn_path = lib_path('foo') - revision = 1 - - gemfile <<-G - source "file://#{gem_repo1}" - - gem "rack", "1.0.0" - svn "file://#{svn_path}", :ref => "#{revision}" do - gem "foo" - end - G - - bundle "install --path vendor/bundle" - - gemfile <<-G - source "file://#{gem_repo1}" - - gem "rack", "1.0.0" - G - bundle "install" - - bundle :clean - - expect(out).to eq("Removing foo (#{revision})") - - expect(vendored_gems("gems/rack-1.0.0")).to exist - expect(vendored_gems("bundler/gems/foo-#{revision}")).not_to exist - expect(vendored_gems("cache/bundler/svn/foo-#{revision}")).not_to exist - - expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist - - expect(vendored_gems("bin/rackup")).to exist - end - it "removes unused git gems" do build_git "foo", :path => lib_path("foo") git_path = lib_path('foo') diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index d6e13494..835b0795 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -307,52 +307,6 @@ describe "bundle exec" do end end - describe "from gems bundled via :svn" do - before(:each) do - build_svn "fizz_svn" do |s| - s.executables = "fizz_svn" - end - - install_gemfile <<-G - gem "fizz_svn", :svn => "file://#{lib_path('fizz_svn-1.0')}" - G - end - - it "works when unlocked" do - bundle "exec fizz_svn" - expect(out).to eq("1.0") - end - - it "works when locked" do - should_be_locked - bundle "exec fizz_svn" - expect(out).to eq("1.0") - end - end - - describe "from gems bundled via :svn with no gemspec" do - before(:each) do - build_svn "fizz_no_gemspec", :gemspec => false do |s| - s.executables = "fizz_no_gemspec" - end - - install_gemfile <<-G - gem "fizz_no_gemspec", "1.0", :svn => "file://#{lib_path('fizz_no_gemspec-1.0')}" - G - end - - it "works when unlocked" do - bundle "exec fizz_no_gemspec" - expect(out).to eq("1.0") - end - - it "works when locked" do - should_be_locked - bundle "exec fizz_no_gemspec" - expect(out).to eq("1.0") - end - end - it "performs an automatic bundle install" do gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 3959e53f..18105541 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -111,22 +111,6 @@ describe "bundle show" do end end - context "with a svn repo in the Gemfile" do - before :each do - @svn = build_svn "foo", "1.0" - end - - it "prints out svn info" do - install_gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - should_be_installed "foo 1.0" - - bundle :show - expect(out).to include("foo (1.0 1") - end - end - context "in a fresh gem in a blank git repo" do before :each do build_git "foo", :path => lib_path("foo") diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index 5f5420ee..26d8abe2 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -46,18 +46,6 @@ describe "install with --deployment or --frozen" do expect(exitstatus).to eq(0) if exitstatus end - it "works if you exclude a group with a svn gem" do - build_svn "foo" - gemfile <<-G - group :test do - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - end - G - bundle :install - bundle "install --deployment --without test" - expect(exitstatus).to eq(0) if exitstatus - end - it "works when you bundle exec bundle" do bundle :install bundle "install --deployment" diff --git a/spec/install/gemfile/svn_spec.rb b/spec/install/gemfile/svn_spec.rb deleted file mode 100644 index bfd3a378..00000000 --- a/spec/install/gemfile/svn_spec.rb +++ /dev/null @@ -1,582 +0,0 @@ -require "spec_helper" - -describe "bundle install with svn sources" do - describe "when floating on master" do - before :each do - build_svn "foo" do |s| - s.executables = "foobar" - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - svn "file://#{lib_path('foo-1.0')}" do - gem 'foo' - end - G - end - - it "sets up svn gem executables on the path" do - pending_jruby_shebang_fix - bundle "exec foobar" - expect(out).to eq("1.0") - end - - it "complains if pinned specs don't exist in the svn repo" do - build_svn "foo" - - install_gemfile <<-G - gem "foo", "1.1", :svn => "file://#{lib_path('foo-1.0')}" - G - - expect(out).to include("Source contains 'foo' at: 1.0") - end - - it "still works after moving the application directory" do - bundle "install --path vendor/bundle" - FileUtils.mv bundled_app, tmp('bundled_app.bck') - - Dir.chdir tmp('bundled_app.bck') - should_be_installed "foo 1.0" - end - - it "can still install after moving the application directory" do - bundle "install --path vendor/bundle" - FileUtils.mv bundled_app, tmp('bundled_app.bck') - - update_svn "foo", "1.1", :path => lib_path("foo-1.0") - - Dir.chdir tmp('bundled_app.bck') - gemfile tmp('bundled_app.bck/Gemfile'), <<-G - source "file://#{gem_repo1}" - svn "file://#{lib_path('foo-1.0')}" do - gem 'foo' - end - - gem "rack", "1.0" - G - - bundle "update foo" - - should_be_installed "foo 1.1", "rack 1.0" - end - - end - - describe "with an empty svn block" do - before do - build_svn "foo" - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - - svn "file://#{lib_path("foo-1.0")}" do - # this page left intentionally blank - end - G - end - - it "does not explode" do - bundle "install" - should_be_installed "rack 1.0" - end - end - - describe "when specifying a revision" do - before(:each) do - build_svn "foo" - @revision = 1 - update_svn "foo" do |s| - s.write "lib/foo.rb", "puts :CACHE" - end - end - - it "works" do - install_gemfile <<-G - svn "file://#{lib_path('foo-1.0')}", :ref => "#{@revision}" do - gem "foo" - end - G - - run <<-RUBY - require 'foo' - RUBY - - expect(out).not_to eq("CACHE") - end - end - - describe "when specifying local override" do - it "uses the local repository instead of checking a new one out" do - # We don't generate it because we actually don't need it - # build_svn "rack", "0.8" - - build_svn "rack", "0.8", :path => lib_path('local-rack') do |s| - s.write "lib/rack.rb", "puts :LOCAL" - end - - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - bundle :install - expect(out).to match(/at #{File.join(lib_path('local-rack'), '.checkout')}/) - - run "require 'rack'" - expect(out).to eq("LOCAL") - end - - it "chooses the local repository on runtime" do - build_svn "rack", "0.8" - - FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack')) - - update_svn "rack", "0.8", :path => lib_path('local-rack') do |s| - s.write "lib/rack.rb", "puts :LOCAL" - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - run "require 'rack'" - expect(out).to eq("LOCAL") - end - - it "updates specs on runtime" do - system_gems "nokogiri-1.4.2" - - build_svn "rack", "0.8" - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - lockfile0 = File.read(bundled_app("Gemfile.lock")) - - FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack')) - update_svn "rack", "0.8", :path => lib_path('local-rack') do |s| - s.add_dependency "nokogiri", "1.4.2" - end - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - run "require 'rack'" - - lockfile1 = File.read(bundled_app("Gemfile.lock")) - expect(lockfile1).not_to eq(lockfile0) - end - - it "updates ref on install" do - build_svn "rack", "0.8" - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - lockfile0 = File.read(bundled_app("Gemfile.lock")) - - FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack')) - update_svn "rack", "0.8", :path => lib_path('local-rack') - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - bundle :install - - lockfile1 = File.read(bundled_app("Gemfile.lock")) - expect(lockfile1).not_to eq(lockfile0) - end - - it "explodes if given path does not exist on install" do - build_svn "rack", "0.8" - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - bundle :install - expect(out).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(File.join(lib_path('local-rack'), '.checkout').to_s)} does not exist/) - end - end - - describe "specified inline" do - it "installs from svn even if a newer gem is available elsewhere" do - build_svn "rack", "0.8" - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}" - G - - should_be_installed "rack 0.8" - end - - it "installs dependencies from svn even if a newer gem is available elsewhere" do - system_gems "rack-1.0.0" - - build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s| - s.write "lib/rack.rb", "puts 'WIN OVERRIDE'" - end - - build_svn "foo", :path => lib_path('nested') do |s| - s.add_dependency "rack", "= 1.0" - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "foo", :svn => "file://#{lib_path('nested')}" - G - - run "require 'rack'" - expect(out).to eq('WIN OVERRIDE') - end - - it "correctly unlocks when changing to a svn source" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", "0.9.1" - G - - build_svn "rack", :path => lib_path("rack") - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", "1.0.0", :svn => "file://#{lib_path('rack')}" - G - - should_be_installed "rack 1.0.0" - end - - it "correctly unlocks when changing to a svn source without versions" do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - - build_svn "rack", "1.2", :path => lib_path("rack") - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack')}" - G - - should_be_installed "rack 1.2" - end - end - - describe "block syntax" do - it "pulls all gems from a svn block" do - build_lib "omg", :path => lib_path('hi2u/omg') - build_lib "hi2u", :path => lib_path('hi2u') - - install_gemfile <<-G - path "#{lib_path('hi2u')}" do - gem "omg" - gem "hi2u" - end - G - - should_be_installed "omg 1.0", "hi2u 1.0" - end - end - - it "uses a ref if specified" do - build_svn "foo" - @revision = 1 - update_svn "foo" do |s| - s.write "lib/foo.rb", "puts :CACHE" - end - - install_gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}", :ref => "#{@revision}" - G - - run <<-RUBY - require 'foo' - RUBY - - expect(out).not_to eq("CACHE") - end - - it "correctly handles cases with invalid gemspecs" do - build_svn "foo" do |s| - s.summary = nil - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - gem "rails", "2.3.2" - G - - should_be_installed "foo 1.0" - should_be_installed "rails 2.3.2" - end - - it "runs the gemspec in the context of its parent directory" do - build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s| - s.write lib_path("foo/bar/lib/version.rb"), %{BAR_VERSION = '1.0'} - s.write "bar.gemspec", <<-G - $:.unshift Dir.pwd # For 1.9 - require 'lib/version' - Gem::Specification.new do |s| - s.name = 'bar' - s.version = BAR_VERSION - s.summary = 'Bar' - s.files = Dir["lib/**/*.rb"] - end - G - end - - build_svn "foo", :path => lib_path("foo") do |s| - s.write "bin/foo", "" - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "bar", :svn => "file://#{lib_path("foo")}" - gem "rails", "2.3.2" - G - - should_be_installed "bar 1.0" - should_be_installed "rails 2.3.2" - end - - it "installs from svn even if a rubygems gem is present" do - build_gem "foo", "1.0", :path => lib_path('fake_foo'), :to_system => true do |s| - s.write "lib/foo.rb", "raise 'FAIL'" - end - - build_svn "foo", "1.0" - - install_gemfile <<-G - gem "foo", "1.0", :svn => "file://#{lib_path('foo-1.0')}" - G - - should_be_installed "foo 1.0" - end - - it "fakes the gem out if there is no gemspec" do - build_svn "foo", :gemspec => false - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "foo", "1.0", :svn => "file://#{lib_path('foo-1.0')}" - gem "rails", "2.3.2" - G - - should_be_installed("foo 1.0") - should_be_installed("rails 2.3.2") - end - - it "catches svn errors and spits out useful output" do - gemfile <<-G - gem "foo", "1.0", :svn => "omgomg" - G - - bundle :install, :expect_err => true - - expect(out).to include("SVN error:") - expect(err).to include("omgomg") - end - - it "doesn't blow up if bundle install is run twice in a row" do - build_svn "foo" - - gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - - bundle "install" - bundle "install" - expect(exitstatus).to eq(0) if exitstatus - end - - it "does not duplicate svn gem sources" do - build_lib "foo", :path => lib_path('nested/foo') - build_lib "bar", :path => lib_path('nested/bar') - - build_svn "foo", :path => lib_path('nested') - build_svn "bar", :path => lib_path('nested') - - gemfile <<-G - gem "foo", :svn => "file://#{lib_path('nested')}" - gem "bar", :svn => "file://#{lib_path('nested')}" - G - - bundle "install" - expect(File.read(bundled_app("Gemfile.lock")).scan('SVN').size).to eq(1) - end - - describe "bundle install after the remote has been updated" do - it "installs" do - build_svn "valim" - - install_gemfile <<-G - gem "valim", :svn => "file://#{lib_path("valim-1.0")}" - G - - old_revision = "1" - update_svn "valim" do |s| - s.write "lib/valim.rb", "puts #{old_revision}" - end - new_revision = "2" - - lockfile = File.read(bundled_app("Gemfile.lock")) - File.open(bundled_app("Gemfile.lock"), "w") do |file| - file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}") - end - - bundle "install" - - run <<-R - require "valim" - R - - expect(out).to eq(old_revision) - end - end - - describe "bundle install --deployment with svn sources" do - it "works" do - build_svn "valim", :path => lib_path('valim') - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "valim", "= 1.0", :svn => "file://#{lib_path('valim')}" - G - - simulate_new_machine - - bundle "install --deployment" - expect(exitstatus).to eq(0) if exitstatus - end - end - - describe "gem install hooks" do - it "runs pre-install hooks" do - build_svn "foo" - gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - - File.open(lib_path("install_hooks.rb"), "w") do |h| - h.write <<-H - require 'rubygems' - Gem.pre_install_hooks << lambda do |inst| - STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}" - end - H - end - - bundle :install, :expect_err => true, - :requires => [lib_path('install_hooks.rb')] - expect(err).to eq("Ran pre-install hook: foo-1.0") - end - - it "runs post-install hooks" do - build_svn "foo" - gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - - File.open(lib_path("install_hooks.rb"), "w") do |h| - h.write <<-H - require 'rubygems' - Gem.post_install_hooks << lambda do |inst| - STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}" - end - H - end - - bundle :install, :expect_err => true, - :requires => [lib_path('install_hooks.rb')] - expect(err).to eq("Ran post-install hook: foo-1.0") - end - - it "complains if the install hook fails" do - build_svn "foo" - gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - - File.open(lib_path("install_hooks.rb"), "w") do |h| - h.write <<-H - require 'rubygems' - Gem.pre_install_hooks << lambda do |inst| - false - end - H - end - - bundle :install, :expect_err => true, - :requires => [lib_path('install_hooks.rb')] - expect(out).to include("failed for foo-1.0") - end - end - - context "with an extension" do - it "installs the extension" do - build_svn "foo" do |s| - s.add_dependency "rake" - s.extensions << "Rakefile" - s.write "Rakefile", <<-RUBY - task :default do - path = File.expand_path("../lib", __FILE__) - FileUtils.mkdir_p(path) - File.open("\#{path}/foo.rb", "w") do |f| - f.puts "FOO = 'YES'" - end - end - RUBY - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "foo", :svn => "file://#{lib_path('foo-1.0')}" - G - - run <<-R - require 'foo' - puts FOO - R - expect(out).to eq("YES") - end - end - - describe "without svn installed" do - it "prints a better error message" do - build_svn "foo" - - install_gemfile <<-G - svn "file://#{lib_path('foo-1.0')}" do - gem 'foo' - end - G - - bundle "update", :env => {"PATH" => ""} - expect(out).to include("You need to install svn to be able to use gems from svn repositories. For help installing svn, please refer to SVNook's tutorial at http://svnbook.red-bean.com/en/1.7/svn.intro.install.html") - end - - it "installs a packaged svn gem successfully" do - build_svn "foo" - - install_gemfile <<-G - svn "file://#{lib_path('foo-1.0')}" do - gem 'foo' - end - G - bundle "package --all" - simulate_new_machine - - bundle "install", :env => {"PATH" => ""} - expect(out).to_not include("You need to install svn to be able to use gems from svn repositories.") - expect(exitstatus).to be_zero if exitstatus - end - end -end diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 4546754e..364b9718 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -209,34 +209,6 @@ describe "the lockfile format" do G end - it "serializes global svn sources" do - build_svn "foo" - - install_gemfile <<-G - svn "file://#{lib_path('foo-1.0')}" do - gem "foo" - end - G - - lockfile_should_be <<-G - SVN - remote: file://#{lib_path('foo-1.0')} - revision: 1 - ref: HEAD - specs: - foo (1.0) - - GEM - specs: - - PLATFORMS - #{generic(Gem::Platform.local)} - - DEPENDENCIES - foo! - G - end - it "generates a lockfile with a ref for a single pinned source, git gem with a branch requirement" do git = build_git "foo" update_git "foo", :branch => "omg" diff --git a/spec/lock/svn_spec.rb b/spec/lock/svn_spec.rb deleted file mode 100644 index 8c2db1eb..00000000 --- a/spec/lock/svn_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "spec_helper" - -describe "bundle lock with svn gems" do - before :each do - build_svn "foo" - - install_gemfile <<-G - gem 'foo', :svn => "file://#{lib_path('foo-1.0')}" - G - end - - it "doesn't break right after running lock" do - should_be_installed "foo 1.0.0" - end - - it "locks a svn source to the current ref" do - update_svn "foo" do |s| - s.write "lib/foo.rb", "puts :CACHE" - end - bundle :install - - run <<-RUBY - require 'foo' - RUBY - - expect(out).not_to eq("CACHE") - end - - it "provides correct #full_gem_path" do - run <<-RUBY - puts Bundler.rubygems.find_name('foo').first.full_gem_path - RUBY - expect(out).to eq(bundle("show foo")) - end -end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index a8f1afe3..896228d1 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -347,17 +347,6 @@ module Spec GitReader.new lib_path(spec.full_name) end - def build_svn(name, *args, &block) - opts = args.last.is_a?(Hash) ? args.last : {} - spec = build_with(SVNBuilder, name, args, &block) - SVNReader.new(opts[:path] || lib_path(spec.full_name)) - end - - def update_svn(name, *args, &block) - spec = build_with(SVNUpdater, name, args, &block) - SVNReader.new lib_path(spec.full_name) - end - private def build_with(builder, name, args, &blk) @@ -610,62 +599,6 @@ module Spec end - class SVNBuilder < LibBuilder - def _build(options) - path = options[:path] || _default_path - checkout_path = File.join(path, '.checkout') - super(options.merge(:path => path)) - Dir.chdir(path) do - `mkdir .repo_data && find . -maxdepth 1 ! \\( -name ".repo_data" -or -name "." \\) -exec mv {} \\.repo_data/ \\;` - `svnadmin create .repo` - `svn import .repo_data file://#{File.join(path, '.repo')} -m 'OMG INITIAL COMMIT'` - `mv .repo/* .` - end - - `mkdir #{checkout_path}` - Dir.chdir(checkout_path) do - `svn checkout file://#{path} .` - end - end - end - - class SVNUpdater < LibBuilder - def _build(options) - path = options[:path] || _default_path - checkout_path = File.join(path, '.checkout') - - Dir.chdir(checkout_path) do - current_ref = `svn info --revision HEAD file://#{checkout_path} | grep \"Revision\" | awk '{print $2}'`.strip - _default_files.keys.each do |prev_ref_path| - _default_files[prev_ref_path] << "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'" - end - super(options.merge(:path => checkout_path, :gemspec => false)) - `svn add --force *` - `svn commit -m "BUMP"` - end - end - end - - class SVNReader - attr_reader :path - - def initialize(path) - @path = path - end - - def ref_for(ref, len = nil) - ref = svn("info --revision #{ref} file://#{path} | grep \"Revision\" | awk '{print $2}'").strip - ref = ref[0..len] if len - ref - end - - private - - def svn(cmd) - Dir.chdir(@path) { `svn #{cmd}`.strip } - end - end - class GemBuilder < LibBuilder def _build(opts) diff --git a/spec/update/svn_spec.rb b/spec/update/svn_spec.rb deleted file mode 100644 index 056d7980..00000000 --- a/spec/update/svn_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require "spec_helper" - -describe "bundle update" do - describe "svn sources" do - it "updates correctly when you have like craziness" do - build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport") - build_svn "rails", "3.0", :path => lib_path("rails") do |s| - s.add_dependency "activesupport", "= 3.0" - end - - install_gemfile <<-G - gem "rails", :svn => "file://#{lib_path('rails')}" - G - - bundle "update rails" - expect(out).to include("Using activesupport 3.0 from file://#{lib_path('rails')} (at HEAD)") - should_be_installed "rails 3.0", "activesupport 3.0" - end - - it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do - build_svn "foo", :path => lib_path('foo') - build_gem "bar", :to_system => true do |s| - s.add_dependency "foo" - end - - install_gemfile <<-G - gem "foo", :svn => "file://#{lib_path('foo')}" - gem "bar" - G - - update_svn "foo", :path => lib_path('foo') do |s| - s.write "lib/foo.rb", "FOO = '1.1'" - end - - bundle "update foo" - - should_be_installed "foo 1.1" - end - - it "notices when you change the repo url in the Gemfile" do - build_svn "foo", :path => lib_path("foo_one") - build_svn "foo", :path => lib_path("foo_two") - - install_gemfile <<-G - gem "foo", "1.0", :svn => "file://#{lib_path('foo_one')}" - G - - FileUtils.rm_rf lib_path("foo_one") - - install_gemfile <<-G - gem "foo", "1.0", :svn => "file://#{lib_path('foo_two')}" - G - - expect(err).to be_empty - expect(out).to include("Fetching file://#{lib_path}/foo_two") - expect(out).to include("Bundle complete!") - end - - it "should not explode on invalid revision on update of gem by name" do - build_svn "rack", "0.8" - - build_svn "rack", "0.8", :path => lib_path('local-rack') do |s| - s.write "lib/rack.rb", "puts :LOCAL" - end - - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rack", :svn => "file://#{lib_path('rack-0.8')}", :branch => "master" - G - - bundle %|config local.rack #{File.join(lib_path('local-rack'), '.checkout')}| - bundle "update rack" - expect(out).to include("Bundle updated!") - end - - it "shows the previous version of the gem" do - build_svn "rails", "3.0", :path => lib_path("rails") - - install_gemfile <<-G - gem "rails", :svn => "file://#{lib_path('rails')}" - G - - lockfile <<-G - SVN - remote: file://#{lib_path("rails")} - specs: - rails (2.3.2) - - PLATFORMS - #{generic(Gem::Platform.local)} - - DEPENDENCIES - rails! - G - - bundle "update" - expect(out).to include("Using rails 3.0 (was 2.3.2) from file://#{lib_path('rails')} (at HEAD)") - end - end -end |