From df22f6f681cfc9d67c27de860104929a908b156a Mon Sep 17 00:00:00 2001 From: Michail Merkushin Date: Fri, 10 Mar 2017 10:34:54 +0500 Subject: [PATCH] Add no-push option --- bin/apress-gem | 4 ++++ lib/apress/gems/cli.rb | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/apress-gem b/bin/apress-gem index e9ccf41..8421657 100755 --- a/bin/apress-gem +++ b/bin/apress-gem @@ -44,6 +44,10 @@ opt_parser = OptionParser.new do |opt| opt.on('-L', '--no-changelog', 'no generate changelog') do options[:changelog] = false end + + opt.on('-P', '--no-push', 'no push to remote repo') do + options[:push] = false + end end opt_parser.parse! diff --git a/lib/apress/gems/cli.rb b/lib/apress/gems/cli.rb index 083c0fb..f72cb0b 100644 --- a/lib/apress/gems/cli.rb +++ b/lib/apress/gems/cli.rb @@ -10,7 +10,7 @@ class Cli GEMS_URL = 'https://gems.railsc.ru/'.freeze def initialize(options) - @options = {bump: true, changelog: true}.merge!(options) + @options = {bump: true, changelog: true, push: true}.merge!(options) @options[:version] = find_version unless @options[:bump] load_gemspec @@ -28,8 +28,11 @@ def bump changelog if @options[:changelog] spawn "git commit -m 'Release #{version}'" - spawn "git push #{remote} #{branch}" - puts 'Changes pushed to repository' + + if @options[:push] + spawn "git push #{remote} #{branch}" + puts 'Changes pushed to repository' + end end def build @@ -51,7 +54,7 @@ def tag tag_name = "v#{version}" spawn "git tag -a -m \"Version #{version}\" #{tag_name}" - spawn "git push --tags #{remote}" + spawn "git push --tags #{remote}" if @options[:push] puts "Git tag generated to #{tag_name}" end