Skip to content

Commit 0c8fbae

Browse files
author
chris flöß
committed
Add --build and --remove option
1 parent 5190753 commit 0c8fbae

File tree

4 files changed

+69
-19
lines changed

4 files changed

+69
-19
lines changed

lib/rubygems/commands/bump_command.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,12 @@ def execute
4040
Dir.chdir(dir) do
4141
cmd=BumpCommand.new(options.merge({:recurse=>false}))
4242
cmd.invoke
43-
## Doesn't seem to be needed now
44-
#build if options[:build]
45-
#commit if options[:commit]
46-
#release if options[:release]
47-
#push if options[:push] || options[:tag]
48-
#tag if options[:tag]
4943
end
5044
end
5145
else
5246
bump
53-
build if options[:build]
5447
commit if options[:commit]
48+
build if options[:build]
5549
release if options[:release]
5650
push if options[:push] || options[:tag]
5751
tag if options[:tag]

lib/rubygems/commands/release_command.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ class Gem::Commands::ReleaseCommand < Gem::Command
66
include GemRelease, Gem::Commands
77
include Helpers, CommandOptions
88

9-
OPTIONS = { :tag => false }
9+
OPTIONS = { :tag => false,
10+
:push => true,
11+
:remove => true }
1012

1113
attr_reader :arguments, :usage
1214

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

2024
def execute
2125
build
22-
push
23-
remove
24-
tag if options[:tag]
26+
push if options[:push]
27+
remove if options[:remove]
28+
tag if options[:tag]
2529
say "All is good, thanks buddy.\n"
2630
end
2731

test/unit/test_recurse.rb renamed to test/unit/test_bump.rb

-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ def teardown
7676
assert_equal '3.3.3', @bump_command.send(:version).target
7777
end
7878

79-
### DANGER: do not run this test because you'll push a bogus gem
80-
##test "can invoke recurse bump with --version 0.8.0 --no-commit --release" do
81-
## assert_nothing_raised do
82-
## @bump_command.invoke('--version', '0.8.0', '--recurse', '--no-commit', '--release')
83-
## end
84-
##end
85-
8679
### DANGER: do not run this test because you'll push a bogus gem
8780
##test "can invoke recurse bump with --version 0.8.0 --no-commit --release" do
8881
## assert_nothing_raised do

test/unit/test_release.rb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require 'pathname'
2+
require 'rubygems'
3+
require 'ruby-debug'
4+
5+
require File.expand_path('../../test_helper', __FILE__)
6+
$: << File.expand_path('../../../lib', __FILE__)
7+
8+
require 'rubygems/commands/bump_command'
9+
require 'rubygems/commands/bootstrap_command'
10+
require 'rubygems/commands/release_command'
11+
12+
class TestRecurse < Test::Unit::TestCase
13+
def setup
14+
@cwd=Dir.pwd
15+
@recursive_specs=['tmp/gem-release-test/repo/',
16+
'tmp/gem-release-test/repo/spec1',
17+
'tmp/gem-release-test/repo/spec2',
18+
'tmp/gem-release-test/repo/spec3',
19+
'tmp/gem-release-test/repo/spec3/spec4']
20+
@recursive_specs.each do |dir|
21+
project = dir.split('/').last
22+
FileUtils.mkdir_p(dir)
23+
Dir.chdir(dir)
24+
bs = BootstrapCommand.new
25+
bs.send(:write_scaffold)
26+
bs.send(:write_gemspec)
27+
FileUtils.touch("#{project}.gemspec")
28+
Dir.chdir(@cwd)
29+
end
30+
31+
@bump_command=klass.new
32+
33+
Dir.chdir('tmp/gem-release-test/repo')
34+
end
35+
36+
def teardown
37+
Dir.chdir(@cwd)
38+
FileUtils.rm_rf('tmp')
39+
end
40+
41+
test "truth" do
42+
assert true
43+
end
44+
45+
test "can instantiate bump command" do
46+
assert defined?(Gem::Commands::ReleaseCommand)
47+
assert_kind_of ReleaseCommand, klass.new
48+
end
49+
50+
protected
51+
def klass
52+
Gem::Commands::ReleaseCommand
53+
end
54+
55+
def specs
56+
['repo.gemspec', 'spec1/spec1.gemspec', 'spec2/spec2.gemspec',
57+
'spec3/spec3.gemspec', 'spec3/spec4/spec4.gemspec']
58+
end
59+
end

0 commit comments

Comments
 (0)