From 8fd67d803451499d9cc9f3a7a3d077e56c079017 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 8 Jan 2025 10:44:50 -0300 Subject: [PATCH] feat: optionally allow to push to other repositories --- lib/rubygems/commands/compile_command.rb | 4 ++++ lib/rubygems/compiler.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/rubygems/commands/compile_command.rb b/lib/rubygems/commands/compile_command.rb index 06dfc38..b4b521b 100644 --- a/lib/rubygems/commands/compile_command.rb +++ b/lib/rubygems/commands/compile_command.rb @@ -54,6 +54,10 @@ def initialize end end + add_option "-u", "--unsafe", "Remove push restrictions" do |_, options| + options[:remove_gemspec_restrictions] = true + end + add_option "--build-number NUMBER", "Append build number to compiled Gem version" do |value, options| diff --git a/lib/rubygems/compiler.rb b/lib/rubygems/compiler.rb index a8c3b8b..c25bf54 100644 --- a/lib/rubygems/compiler.rb +++ b/lib/rubygems/compiler.rb @@ -68,6 +68,11 @@ def adjust_gemspec_files(gemspec, artifacts) gemspec.files.reject! { |f| !File.exist?("#{target_dir}/#{f}") } end + if @options[:remove_gemspec_restrictions] + gemspec.metadata.delete 'allowed_push_host' + gemspec.metadata.delete 'rubygems_mfa_required' + end + # add discovered artifacts artifacts.each do |path| # path needs to be relative to target_dir