aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-06-24 11:15:17 +0900
committerSamuel Giddins <segiddins@segiddins.me>2016-06-27 16:17:38 -0500
commit0f441e83fe4988d86c928aad0fe6f6cb908c6aab (patch)
tree0e39d063166eca73d1f5d8274ff266485edcb831 /lib
parent63622905967db5766305df374d19eda9d4045776 (diff)
downloadbundler-0f441e83fe4988d86c928aad0fe6f6cb908c6aab.tar.gz
Auto merge of #4702 - bundler:seg-major-deprecations, r=indirect
Add machinery for printing major deprecations First step towards handling all of #4695 \c @RochesterinNYC @indirect (cherry picked from commit dca6d26833ddd9d9de658bef7274c8fa21014c44)
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler.rb3
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/deprecate.rb16
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/settings.rb30
-rw-r--r--lib/bundler/shared_helpers.rb23
-rw-r--r--lib/bundler/ui/shell.rb16
-rw-r--r--lib/bundler/ui/silent.rb3
8 files changed, 85 insertions, 10 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 9cfc7157..4aa0abe2 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -92,6 +92,8 @@ module Bundler
definition.validate_ruby!
+ SharedHelpers.print_major_deprecations!
+
if groups.empty?
# Load all groups, but only once
@setup = load.setup
@@ -209,6 +211,7 @@ module Bundler
# @deprecated Use `original_env` instead
# @return [Hash] Environment with all bundler-related variables removed
def clean_env
+ Bundler::SharedHelpers.major_deprecation("`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
env = original_env
if env.key?("BUNDLE_ORIG_MANPATH")
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index c3a9a01e..1fb4b1bd 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -12,6 +12,8 @@ module Bundler
rescue Exception => e
Bundler.ui = UI::Shell.new
raise e
+ ensure
+ Bundler::SharedHelpers.print_major_deprecations!
end
def initialize(*args)
diff --git a/lib/bundler/deprecate.rb b/lib/bundler/deprecate.rb
index 1ab4de1a..b978c0df 100644
--- a/lib/bundler/deprecate.rb
+++ b/lib/bundler/deprecate.rb
@@ -10,7 +10,23 @@ module Bundler
unless Deprecate.respond_to?(:skip_during)
def Deprecate.skip_during
+ original = skip
+ self.skip = true
yield
+ ensure
+ self.skip = original
+ end
+ end
+
+ unless Deprecate.respond_to?(:skip)
+ def Deprecate.skip
+ @skip
+ end
+ end
+
+ unless Deprecate.respond_to?(:skip=)
+ def Deprecate.skip=(skip)
+ @skip = skip
end
end
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 4208f9b5..358784a9 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -374,7 +374,7 @@ module Bundler
def normalize_source(source)
case source
when :gemcutter, :rubygems, :rubyforge
- Bundler.ui.warn "The source :#{source} is deprecated because HTTP " \
+ Bundler::SharedHelpers.major_deprecation "The source :#{source} is deprecated because HTTP " \
"requests are insecure.\nPlease change your source to 'https://" \
"rubygems.org' if possible, or 'http://rubygems.org' if not."
"http://rubygems.org"
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 0dd1d762..46333c89 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -3,9 +3,33 @@ require "uri"
module Bundler
class Settings
- BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check disable_shared_gems ignore_messages gem.mit gem.coc silence_root_warning no_install plugins).freeze
- NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze
- DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }.freeze
+ BOOL_KEYS = %w(
+ cache_all
+ disable_local_branch_check
+ disable_shared_gems
+ frozen
+ gem.coc
+ gem.mit
+ ignore_messages
+ major_deprecations
+ no_install
+ no_prune
+ plugins
+ silence_root_warning
+ ).freeze
+
+ NUMBER_KEYS = %w(
+ redirect
+ retry
+ ssl_verify_mode
+ timeout
+ ).freeze
+
+ DEFAULT_CONFIG = {
+ :redirect => 5,
+ :retry => 3,
+ :timeout => 10,
+ }.freeze
def initialize(root = nil)
@root = root
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 01f1118d..df0fffba 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -120,6 +120,21 @@ module Bundler
namespace.const_get(constant_name)
end
+ def major_deprecation(message)
+ return unless prints_major_deprecations?
+ @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
+ ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
+ ui.warn("[DEPRECATED FOR #{Bundler::VERSION.split(".").first.to_i + 1}.0] #{message}")
+ end
+
+ def print_major_deprecations!
+ if RUBY_VERSION < "2"
+ major_deprecation("Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}")
+ end
+ return if Bundler.rubygems.provides?(">= 2")
+ major_deprecation("Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
+ end
+
private
def find_gemfile
@@ -207,6 +222,14 @@ module Bundler
end
end
+ def prints_major_deprecations?
+ require "bundler"
+ return false unless Bundler.settings[:major_deprecations]
+ require "bundler/deprecate"
+ return false if Bundler::Deprecate.skip
+ true
+ end
+
extend self
end
end
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 1317b183..df41d727 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -79,12 +79,8 @@ module Bundler
tell_me(msg, nil, newline)
end
- def silence
- old_level = @level
- @level = "silent"
- yield
- ensure
- @level = old_level
+ def silence(&blk)
+ with_level("silent", &blk)
end
private
@@ -109,6 +105,14 @@ module Bundler
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
end * "\n"
end
+
+ def with_level(level)
+ original = @level
+ @level = level
+ yield
+ ensure
+ @level = original
+ end
end
end
end
diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb
index af512ece..02978fc6 100644
--- a/lib/bundler/ui/silent.rb
+++ b/lib/bundler/ui/silent.rb
@@ -40,6 +40,9 @@ module Bundler
def trace(message, newline = nil)
end
+ def major_deprecation(message)
+ end
+
def silence
yield
end