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

Commit

Permalink
Merge #7437
Browse files Browse the repository at this point in the history
7437: Extra patches for 2.1.0.pre.3 r=deivid-rodriguez a=deivid-rodriguez

### What was the end-user problem that led to this PR?

The problem was that before releasing 2.1.0.pre.3 I found some issues when integrating the new version into rubygems.

### What is your fix for the problem, implemented in this PR?

My fix is to add the patches fixing the issues I found to the upcoming release.


Co-authored-by: Bundlerbot <[email protected]>
Co-authored-by: David Rodríguez <[email protected]>
  • Loading branch information
bundlerbot and deivid-rodriguez committed Nov 12, 2019
2 parents 27ae250 + 9891946 commit 9e06edc
Show file tree
Hide file tree
Showing 39 changed files with 195 additions and 284 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: ruby
dist: bionic
script: bin/rake spec:travis
before_script:
- gem install rake:"~> 12.0"
- bin/rake override_version
- travis_retry gem install rake:"~> 12.0"
- travis_retry bin/rake override_version
- travis_retry bin/rake spec:travis:deps
- bin/rake man:check

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 2.1.0.pre.3 (November 8, 2019)
## 2.1.0.pre.3 (November 12, 2019)

Features:

Expand Down
1 change: 0 additions & 1 deletion lib/bundler/gem_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require_relative "vendored_thor" unless defined?(Thor)
require_relative "../bundler"
require "shellwords"

Expand Down
7 changes: 5 additions & 2 deletions lib/bundler/vendor/thor/lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def command_help(shell, command_name)
handle_no_command_error(meth) unless command

shell.say "Usage:"
shell.say " #{banner(command)}"
shell.say " #{banner(command).split("\n").join("\n ")}"
shell.say
class_options_help(shell, nil => command.options.values)
if command.long_description
Expand Down Expand Up @@ -398,7 +398,10 @@ def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable Me
# the namespace should be displayed as arguments.
#
def banner(command, namespace = nil, subcommand = false)
"#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
$thor_runner ||= false
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
"#{basename} #{formatted_usage}"
end.join("\n")
end

def baseclass #:nodoc:
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/vendor/thor/lib/thor/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Actions
attr_accessor :behavior

def self.included(base) #:nodoc:
super(base)
base.extend ClassMethods
end

Expand Down
22 changes: 6 additions & 16 deletions lib/bundler/vendor/thor/lib/thor/actions/directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Directory < EmptyDirectory #:nodoc:
attr_reader :source

def initialize(base, source, destination = nil, config = {}, &block)
@source = File.expand_path(base.find_in_source_paths(source.to_s))
@source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
@block = block
super(base, destination, {:recursive => true}.merge(config))
end
Expand Down Expand Up @@ -96,22 +96,12 @@ def execute!
end
end

if RUBY_VERSION < "2.0"
def file_level_lookup(previous_lookup)
File.join(previous_lookup, "{*,.[a-z]*}")
end

def files(lookup)
Dir[lookup]
end
else
def file_level_lookup(previous_lookup)
File.join(previous_lookup, "*")
end
def file_level_lookup(previous_lookup)
File.join(previous_lookup, "*")
end

def files(lookup)
Dir.glob(lookup, File::FNM_DOTMATCH)
end
def files(lookup)
Dir.glob(lookup, File::FNM_DOTMATCH)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def copy_file(source, *args, &block)
destination = args.first || source
source = File.expand_path(find_in_source_paths(source.to_s))

create_file destination, nil, config do
resulting_destination = create_file destination, nil, config do
content = File.binread(source)
content = yield(content) if block
content
end
if config[:mode] == :preserve
mode = File.stat(source).mode
chmod(destination, mode, config)
chmod(resulting_destination, mode, config)
end
end

Expand Down Expand Up @@ -80,14 +80,14 @@ def get(source, *args, &block)
config = args.last.is_a?(Hash) ? args.pop : {}
destination = args.first

if source =~ %r{^https?\://}
render = if source =~ %r{^https?\://}
require "open-uri"
URI.send(:open, source) { |input| input.binmode.read }
else
source = File.expand_path(find_in_source_paths(source.to_s))
open(source) { |input| input.binmode.read }
end

render = open(source) { |input| input.binmode.read }

destination ||= if block_given?
block.arity == 1 ? yield(render) : yield
else
Expand Down
25 changes: 18 additions & 7 deletions lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ module Actions
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }

def insert_into_file(destination, *args, &block)
data = block_given? ? block : args.shift
config = args.shift

config = args.shift || {}
config[:after] = /\z/ unless config.key?(:before) || config.key?(:after)

action InjectIntoFile.new(self, destination, data, config)
end
alias_method :inject_into_file, :insert_into_file
Expand All @@ -45,16 +50,18 @@ def initialize(base, destination, data, config)
end

def invoke!
say_status :invoke

content = if @behavior == :after
'\0' + replacement
else
replacement + '\0'
end

if exists?
replace!(/#{flag}/, content, config[:force])
if replace!(/#{flag}/, content, config[:force])
say_status(:invoke)
else
say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
end
else
unless pretend?
raise Bundler::Thor::Error, "The file #{ destination } does not appear to exist"
Expand All @@ -78,7 +85,7 @@ def revoke!

protected

def say_status(behavior)
def say_status(behavior, warning: nil, color: nil)
status = if behavior == :invoke
if flag == /\A/
:prepend
Expand All @@ -87,11 +94,13 @@ def say_status(behavior)
else
:insert
end
elsif warning
warning
else
:subtract
end

super(status, config[:verbose])
super(status, (color || config[:verbose]))
end

# Adds the content to the file.
Expand All @@ -100,8 +109,10 @@ def replace!(regexp, string, force)
return if pretend?
content = File.read(destination)
if force || !content.include?(replacement)
content.gsub!(regexp, string)
success = content.gsub!(regexp, string)

File.open(destination, "wb") { |file| file.write(content) }
success
end
end
end
Expand Down
18 changes: 10 additions & 8 deletions lib/bundler/vendor/thor/lib/thor/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require_relative "command"
require_relative "core_ext/hash_with_indifferent_access"
require_relative "core_ext/ordered_hash"
require_relative "error"
require_relative "invocation"
require_relative "parser"
Expand Down Expand Up @@ -89,6 +88,7 @@ def initialize(args = [], local_options = {}, config = {})

class << self
def included(base) #:nodoc:
super(base)
base.extend ClassMethods
base.send :include, Invocation
base.send :include, Shell
Expand Down Expand Up @@ -353,22 +353,22 @@ def group(name = nil)
# Returns the commands for this Bundler::Thor class.
#
# ==== Returns
# OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
# objects as values.
# Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
# objects as values.
#
def commands
@commands ||= Bundler::Thor::CoreExt::OrderedHash.new
@commands ||= Hash.new
end
alias_method :tasks, :commands

# Returns the commands for this Bundler::Thor class and all subclasses.
#
# ==== Returns
# OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
# objects as values.
# Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
# objects as values.
#
def all_commands
@all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new)
@all_commands ||= from_superclass(:all_commands, Hash.new)
@all_commands.merge!(commands)
end
alias_method :all_tasks, :all_commands
Expand Down Expand Up @@ -502,7 +502,7 @@ def handle_argument_error(command, error, args, arity) #:nodoc:
msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
msg << "no arguments" if args.empty?
msg << "arguments " << args.inspect unless args.empty?
msg << "\nUsage: #{banner(command).inspect}"
msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
raise InvocationError, msg
end

Expand Down Expand Up @@ -596,13 +596,15 @@ def find_and_refresh_command(name) #:nodoc:
# Everytime someone inherits from a Bundler::Thor class, register the klass
# and file into baseclass.
def inherited(klass)
super(klass)
Bundler::Thor::Base.register_klass_file(klass)
klass.instance_variable_set(:@no_commands, false)
end

# Fire this callback whenever a method is added. Added methods are
# tracked as commands by invoking the create_command method.
def method_added(meth)
super(meth)
meth = meth.to_s

if meth == "initialize"
Expand Down
35 changes: 21 additions & 14 deletions lib/bundler/vendor/thor/lib/thor/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,32 @@ def formatted_usage(klass, namespace = true, subcommand = false)

formatted ||= "".dup

# Add usage with required arguments
formatted << if klass && !klass.arguments.empty?
usage.to_s.gsub(/^#{name}/) do |match|
match << " " << klass.arguments.map(&:usage).compact.join(" ")
end
else
usage.to_s
end
Array(usage).map do |specific_usage|
formatted_specific_usage = formatted

# Add required options
formatted << " #{required_options}"
formatted_specific_usage += required_arguments_for(klass, specific_usage)

# Strip and go!
formatted.strip
# Add required options
formatted_specific_usage += " #{required_options}"

# Strip and go!
formatted_specific_usage.strip
end.join("\n")
end

protected

# Add usage with required arguments
def required_arguments_for(klass, usage)
if klass && !klass.arguments.empty?
usage.to_s.gsub(/^#{name}/) do |match|
match << " " << klass.arguments.map(&:usage).compact.join(" ")
end
else
usage.to_s
end
end

def not_debugging?(instance)
!(instance.class.respond_to?(:debugging) && instance.class.debugging)
end
Expand Down Expand Up @@ -97,8 +105,7 @@ def sans_backtrace(backtrace, caller) #:nodoc:
def handle_argument_error?(instance, error, caller)
not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
saned = sans_backtrace(error.backtrace, caller)
# Ruby 1.9 always include the called method in the backtrace
saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
saned.empty? || saned.size == 1
end
end

Expand Down
Loading

0 comments on commit 9e06edc

Please sign in to comment.