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