Blame SOURCES/rubygems-3.0.3-Restore-gem-build-behavior-and-introdcue-the-C-flag-to-gem-build.patch

a54e24
From f4061357d812e9033f07ae3f8f44c4e26839f1e5 Mon Sep 17 00:00:00 2001
a54e24
From: bronzdoc <lsagastume1990@gmail.com>
a54e24
Date: Mon, 14 Jan 2019 09:46:29 -0600
a54e24
Subject: [PATCH] Restore gem build behavior and introdcue the "-C" flag to gem
a54e24
 build
a54e24
a54e24
---
a54e24
 lib/rubygems/commands/build_command.rb        | 41 +++++++++++++------
a54e24
 .../test_gem_commands_build_command.rb        |  1 +
a54e24
 2 files changed, 29 insertions(+), 13 deletions(-)
a54e24
a54e24
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
a54e24
index e59471e976..761b80ee94 100644
a54e24
--- a/lib/rubygems/commands/build_command.rb
a54e24
+++ b/lib/rubygems/commands/build_command.rb
a54e24
@@ -18,6 +18,10 @@ def initialize
a54e24
     add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
a54e24
       options[:output] = value
a54e24
     end
a54e24
+
a54e24
+    add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
a54e24
+      options[:build_path] = value
a54e24
+    end
a54e24
   end
a54e24
 
a54e24
   def arguments # :nodoc:
a54e24
@@ -60,25 +64,36 @@ def execute
a54e24
     end
a54e24
 
a54e24
     if File.exist? gemspec
a54e24
-      Dir.chdir(File.dirname(gemspec)) do
a54e24
-        spec = Gem::Specification.load File.basename(gemspec)
a54e24
-
a54e24
-        if spec
a54e24
-          Gem::Package.build(
a54e24
-            spec,
a54e24
-            options[:force],
a54e24
-            options[:strict],
a54e24
-            options[:output]
a54e24
-          )
a54e24
-        else
a54e24
-          alert_error "Error loading gemspec. Aborting."
a54e24
-          terminate_interaction 1
a54e24
+      spec = Gem::Specification.load(gemspec)
a54e24
+
a54e24
+      if options[:build_path]
a54e24
+        Dir.chdir(File.dirname(gemspec)) do
a54e24
+          spec = Gem::Specification.load File.basename(gemspec)
a54e24
+          build_package(spec)
a54e24
         end
a54e24
+      else
a54e24
+        build_package(spec)
a54e24
       end
a54e24
+
a54e24
     else
a54e24
       alert_error "Gemspec file not found: #{gemspec}"
a54e24
       terminate_interaction 1
a54e24
     end
a54e24
   end
a54e24
 
a54e24
+  private
a54e24
+
a54e24
+  def build_package(spec)
a54e24
+    if spec
a54e24
+      Gem::Package.build(
a54e24
+        spec,
a54e24
+        options[:force],
a54e24
+        options[:strict],
a54e24
+        options[:output]
a54e24
+      )
a54e24
+    else
a54e24
+      alert_error "Error loading gemspec. Aborting."
a54e24
+      terminate_interaction 1
a54e24
+    end
a54e24
+  end
a54e24
 end
a54e24
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
a54e24
index ac82a408c7..02d1b98e8f 100644
a54e24
--- a/test/rubygems/test_gem_commands_build_command.rb
a54e24
+++ b/test/rubygems/test_gem_commands_build_command.rb
a54e24
@@ -207,6 +207,7 @@ def test_execute_outside_dir
a54e24
       gs.write @gem.to_ruby
a54e24
     end
a54e24
 
a54e24
+    @cmd.options[:build_path] = gemspec_dir
a54e24
     @cmd.options[:args] = [gemspec_file]
a54e24
 
a54e24
     use_ui @ui do