Skip to content

Commit

Permalink
Add no-push option
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Mar 10, 2017
1 parent dcbb238 commit df22f6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bin/apress-gem
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
11 changes: 7 additions & 4 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}.merge!(options)
@options = {bump: true, changelog: true, push: true}.merge!(options)
@options[:version] = find_version unless @options[:bump]

load_gemspec
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit df22f6f

Please sign in to comment.