Skip to content

Commit

Permalink
Add --build and --remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
chris flöß committed Nov 22, 2010
1 parent 5190753 commit 0c8fbae
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 19 deletions.
8 changes: 1 addition & 7 deletions lib/rubygems/commands/bump_command.rb
Expand Up @@ -40,18 +40,12 @@ def execute
Dir.chdir(dir) do
cmd=BumpCommand.new(options.merge({:recurse=>false}))
cmd.invoke
## Doesn't seem to be needed now
#build if options[:build]
#commit if options[:commit]
#release if options[:release]
#push if options[:push] || options[:tag]
#tag if options[:tag]
end
end
else
bump
build if options[:build]
commit if options[:commit]
build if options[:build]
release if options[:release]
push if options[:push] || options[:tag]
tag if options[:tag]
Expand Down
14 changes: 9 additions & 5 deletions lib/rubygems/commands/release_command.rb
Expand Up @@ -6,22 +6,26 @@ class Gem::Commands::ReleaseCommand < Gem::Command
include GemRelease, Gem::Commands
include Helpers, CommandOptions

OPTIONS = { :tag => false }
OPTIONS = { :tag => false,
:push => true,
:remove => true }

attr_reader :arguments, :usage

def initialize
super 'release', 'Build gem from a gemspec and push to rubygems.org'
option :tag, '-t', 'Create a git tag and push --tags to origin'
option :tag, '-t', 'Create a git tag and push --tags to origin'
option :push, '-p', 'Push to rubygems.org'
option :remove, '-R', 'Remove *.gem afterwards'
@arguments = "gemspec - optional gemspec file name, will use the first *.gemspec if not specified"
@usage = "#{program_name} [gemspec]"
end

def execute
build
push
remove
tag if options[:tag]
push if options[:push]
remove if options[:remove]
tag if options[:tag]
say "All is good, thanks buddy.\n"
end

Expand Down
7 changes: 0 additions & 7 deletions test/unit/test_recurse.rb → test/unit/test_bump.rb
Expand Up @@ -76,13 +76,6 @@ def teardown
assert_equal '3.3.3', @bump_command.send(:version).target
end

### DANGER: do not run this test because you'll push a bogus gem
##test "can invoke recurse bump with --version 0.8.0 --no-commit --release" do
## assert_nothing_raised do
## @bump_command.invoke('--version', '0.8.0', '--recurse', '--no-commit', '--release')
## end
##end

### DANGER: do not run this test because you'll push a bogus gem
##test "can invoke recurse bump with --version 0.8.0 --no-commit --release" do
## assert_nothing_raised do
Expand Down
59 changes: 59 additions & 0 deletions test/unit/test_release.rb
@@ -0,0 +1,59 @@
require 'pathname'
require 'rubygems'
require 'ruby-debug'

require File.expand_path('../../test_helper', __FILE__)
$: << File.expand_path('../../../lib', __FILE__)

require 'rubygems/commands/bump_command'
require 'rubygems/commands/bootstrap_command'
require 'rubygems/commands/release_command'

class TestRecurse < Test::Unit::TestCase
def setup
@cwd=Dir.pwd
@recursive_specs=['tmp/gem-release-test/repo/',
'tmp/gem-release-test/repo/spec1',
'tmp/gem-release-test/repo/spec2',
'tmp/gem-release-test/repo/spec3',
'tmp/gem-release-test/repo/spec3/spec4']
@recursive_specs.each do |dir|
project = dir.split('/').last
FileUtils.mkdir_p(dir)
Dir.chdir(dir)
bs = BootstrapCommand.new
bs.send(:write_scaffold)
bs.send(:write_gemspec)
FileUtils.touch("#{project}.gemspec")
Dir.chdir(@cwd)
end

@bump_command=klass.new

Dir.chdir('tmp/gem-release-test/repo')
end

def teardown
Dir.chdir(@cwd)
FileUtils.rm_rf('tmp')
end

test "truth" do
assert true
end

test "can instantiate bump command" do
assert defined?(Gem::Commands::ReleaseCommand)
assert_kind_of ReleaseCommand, klass.new
end

protected
def klass
Gem::Commands::ReleaseCommand
end

def specs
['repo.gemspec', 'spec1/spec1.gemspec', 'spec2/spec2.gemspec',
'spec3/spec3.gemspec', 'spec3/spec4/spec4.gemspec']
end
end

0 comments on commit 0c8fbae

Please sign in to comment.