From 1f62a98f737285e1e5bf3262081b5205a6d139f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 6 Nov 2024 19:01:15 +0100 Subject: [PATCH] [rubygems/rubygems] Remove no longer necessary hacks to define the `gem` command We did this because RubyGems `require` would call `gem` on self, so defining a `gem` method in the CLI would cause conflicts. However, this is not the case since https://github.com/rubygems/rubygems/commit/439c4464890958fec17b3aa65b9d3a4dbdd3bf90, so this should no longer be necessary. https://github.com/rubygems/rubygems/commit/3e5c861046 --- lib/bundler/cli.rb | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 18c41f9be6..fb6599636b 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -539,8 +539,6 @@ module Bundler end end - old_gem = instance_method(:gem) - desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem" method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], desc: "Generate a binary executable for your library." method_option :coc, type: :boolean, desc: "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`." @@ -564,30 +562,13 @@ module Bundler method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username `." def gem(name) + require_relative "cli/gem" + cmd_args = args + [self] + cmd_args.unshift(options) + + Gem.new(*cmd_args).run end - commands["gem"].tap do |gem_command| - def gem_command.run(instance, args = []) - arity = 1 # name - - require_relative "cli/gem" - cmd_args = args + [instance] - cmd_args.unshift(instance.options) - - cmd = begin - Gem.new(*cmd_args) - rescue ArgumentError => e - instance.class.handle_argument_error(self, e, args, arity) - end - - cmd.run - end - end - - undef_method(:gem) - define_method(:gem, old_gem) - private :gem - def self.source_root File.expand_path("templates", __dir__) end