From a0bdddc5df53fc0442062744eefab57bc409470c Mon Sep 17 00:00:00 2001 From: Michail Merkushin Date: Fri, 10 Mar 2017 11:17:15 +0500 Subject: [PATCH] Add no-pull option --- bin/apress-gem | 4 ++++ lib/apress/gems/cli.rb | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/apress-gem b/bin/apress-gem index 8421657..55467a1 100755 --- a/bin/apress-gem +++ b/bin/apress-gem @@ -48,6 +48,10 @@ opt_parser = OptionParser.new do |opt| opt.on('-P', '--no-push', 'no push to remote repo') do options[:push] = false end + + opt.on('-U', '--no-pull', 'no pull latest changes') do + options[:pull] = false + end end opt_parser.parse! diff --git a/lib/apress/gems/cli.rb b/lib/apress/gems/cli.rb index f72cb0b..3183867 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, push: true}.merge!(options) + @options = {bump: true, changelog: true, pull: true, push: true}.merge!(options) @options[:version] = find_version unless @options[:bump] load_gemspec @@ -64,7 +64,7 @@ def current end def release - check_git + pull_latest if @options[:pull] bump if @options[:bump] tag build @@ -108,7 +108,7 @@ def upload_uri uri end - def check_git + def pull_latest `git rev-parse --abbrev-ref HEAD`.chomp.strip == branch || abort("Can be released only from `#{branch}` branch") `git remote | grep #{remote}`.chomp.strip == remote || abort("Can be released only with `#{remote}` remote") spawn "git pull #{remote} #{branch}"