Skip to content

Commit

Permalink
Add no-pull option
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Mar 10, 2017
1 parent df22f6f commit a0bdddc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bin/apress-gem
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
6 changes: 3 additions & 3 deletions lib/apress/gems/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,7 +64,7 @@ def current
end

def release
check_git
pull_latest if @options[:pull]
bump if @options[:bump]
tag
build
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit a0bdddc

Please sign in to comment.