knife-community 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.md +5 -0
- data/Rakefile +6 -1
- data/lib/chef/knife/community_release.rb +23 -7
- data/lib/knife-community/version.rb +1 -1
- data/spec/community_spec.rb +41 -0
- data/spec/spec_helper.rb +15 -0
- metadata +5 -3
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v0.2.0 - May 2, 2013
|
2
|
+
|
3
|
+
- Enhancement: Added a flag for `--tag-prefix` (GH-9, requested by @fnichol)
|
4
|
+
- General: started adding rspec unit tests to get better test coverage
|
5
|
+
|
1
6
|
# v0.1.1 - March 1, 2013
|
2
7
|
|
3
8
|
- BugFix: Version bumper was updating more than it should, in the case where a version string was found more than once in `metadata.rb`.
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
|
4
|
-
task :default => [:features, :tailor]
|
4
|
+
task :default => [:spec, :features, :tailor]
|
5
5
|
|
6
6
|
# https://github.com/turboladen/tailor
|
7
7
|
require 'tailor/rake_task'
|
@@ -18,6 +18,11 @@ Cucumber::Rake::Task.new(:features) do |t|
|
|
18
18
|
t.cucumber_opts += ['--format pretty']
|
19
19
|
end
|
20
20
|
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
23
|
+
t.rspec_opts = "--color"
|
24
|
+
end
|
25
|
+
|
21
26
|
# https://github.com/guard/guard
|
22
27
|
require 'guard'
|
23
28
|
desc "Start up guard, does not exit until told to with 'q'."
|
@@ -46,31 +46,41 @@ module KnifeCommunity
|
|
46
46
|
:default => true,
|
47
47
|
:description => "Indicates whether the commits and tags should be pushed to pushed to the default git remote."
|
48
48
|
|
49
|
+
option :tag_prefix,
|
50
|
+
:long => "--tag-prefix TAGPREFIX",
|
51
|
+
:description => "Prefix for Git tag name, followed by version"
|
52
|
+
|
49
53
|
option :site_share,
|
50
54
|
:long => "--[no-]site-share",
|
51
55
|
:boolean => true,
|
52
56
|
:default => true,
|
53
57
|
:description => "Indicates whether the cookbook should be pushed to the community site."
|
54
58
|
|
55
|
-
def
|
59
|
+
def setup
|
56
60
|
self.config = Chef::Config.merge!(config)
|
57
61
|
validate_args
|
58
62
|
# Set variables for global use
|
59
63
|
@cookbook = name_args.first
|
60
64
|
@version = Versionomy.parse(name_args.last) if name_args.size > 1
|
65
|
+
return @cookbook, @version, config
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
self.setup
|
61
70
|
|
62
71
|
ui.msg "Starting to validate the envrionment before changing anything..."
|
63
72
|
validate_cookbook_exists
|
64
73
|
validate_repo
|
65
74
|
validate_repo_clean
|
66
75
|
validate_version_sanity
|
67
|
-
validate_no_existing_tag
|
76
|
+
validate_no_existing_tag(get_tag_string)
|
77
|
+
# TODO: skip next step if --no-git-push is provided
|
68
78
|
validate_target_remote_branch
|
69
79
|
|
70
80
|
ui.msg "All validation steps have passed, making changes..."
|
71
81
|
set_new_cb_version
|
72
82
|
commit_new_cb_version
|
73
|
-
tag_new_cb_version
|
83
|
+
tag_new_cb_version(get_tag_string)
|
74
84
|
|
75
85
|
if config[:git_push]
|
76
86
|
git_push_commits
|
@@ -180,6 +190,7 @@ module KnifeCommunity
|
|
180
190
|
if @version.nil?
|
181
191
|
@version = @cb_version.bump(:tiny)
|
182
192
|
ui.msg "No version was specified, the new version will be #{@version}"
|
193
|
+
return @version
|
183
194
|
end
|
184
195
|
if @cb_version >= @version
|
185
196
|
ui.error "The current version, #{@cb_version} is either greater or equal to the new version, #{@version}"
|
@@ -189,10 +200,10 @@ module KnifeCommunity
|
|
189
200
|
end
|
190
201
|
|
191
202
|
# Ensure that there isn't already a git tag for this version.
|
192
|
-
def validate_no_existing_tag
|
203
|
+
def validate_no_existing_tag(tag_string)
|
193
204
|
existing_tags = Array.new
|
194
205
|
@gitrepo.tags.each { |tag| existing_tags << tag.name }
|
195
|
-
if existing_tags.include?(
|
206
|
+
if existing_tags.include?(tag_string)
|
196
207
|
ui.error "This version tag has already been committed to the repo."
|
197
208
|
ui.error "Are you sure you haven't released this already?"
|
198
209
|
exit 6
|
@@ -226,8 +237,13 @@ module KnifeCommunity
|
|
226
237
|
@gitrepo.commit_index("release v#{@version}")
|
227
238
|
end
|
228
239
|
|
229
|
-
|
230
|
-
|
240
|
+
# Returns the desired tag string, based on config option
|
241
|
+
def get_tag_string
|
242
|
+
config[:tag_prefix] ? "#{config[:tag_prefix]}#{@version.to_s}" : @version.to_s
|
243
|
+
end
|
244
|
+
|
245
|
+
def tag_new_cb_version(tag_string)
|
246
|
+
shellout("git tag -a -m 'release v#{@version}' #{tag_string}")
|
231
247
|
end
|
232
248
|
|
233
249
|
# Apparently Grit does not have any `push` semantics yet.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# # Here we expose any proviate methods that we want tested
|
4
|
+
# # There may be other ways to do this, I'm no rspec expert
|
5
|
+
class KnifeCommunity::CommunityRelease
|
6
|
+
public :get_tag_string
|
7
|
+
end
|
8
|
+
|
9
|
+
describe KnifeCommunity::CommunityRelease do
|
10
|
+
|
11
|
+
describe "options" do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@runner = KnifeCommunity::CommunityRelease.new
|
15
|
+
@runner.name_args = ["apache2", "0.1.0"]
|
16
|
+
@runner.setup
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "version string handling" do
|
20
|
+
it "should use the provided version string" do
|
21
|
+
@runner.setup[1].to_s.should == "0.1.0"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "version tag prefix handling" do
|
26
|
+
it "should not prepend the tagprefix when not provided" do
|
27
|
+
@runner.get_tag_string.should == "0.1.0"
|
28
|
+
end
|
29
|
+
it "should not prepend tagprefix when none specified" do
|
30
|
+
@runner.options[:tag_prefix] = nil
|
31
|
+
@runner.get_tag_string.should == "0.1.0"
|
32
|
+
end
|
33
|
+
it "should prepend the tagprefix when provided" do
|
34
|
+
@runner.config[:tag_prefix] = "v"
|
35
|
+
@runner.get_tag_string.should == "v0.1.0"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,17 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
# Load any custom matchers
|
3
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
|
4
|
+
|
2
5
|
require 'chef/knife/community_release'
|
6
|
+
|
7
|
+
# everything from KnifeCommunity::CommunityRelease#deps here as well
|
8
|
+
# FIXME: Why do I have to re-require everything?
|
9
|
+
require 'knife-community/version'
|
10
|
+
require 'mixlib/shellout'
|
11
|
+
require 'chef/config'
|
12
|
+
require 'chef/cookbook_loader'
|
13
|
+
require 'chef/knife/cookbook_site_share'
|
14
|
+
require 'chef/cookbook_site_streaming_uploader'
|
15
|
+
require 'grit'
|
16
|
+
require 'versionomy'
|
17
|
+
require 'json'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-community
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- knife-community.gemspec
|
199
199
|
- lib/chef/knife/community_release.rb
|
200
200
|
- lib/knife-community/version.rb
|
201
|
+
- spec/community_spec.rb
|
201
202
|
- spec/spec_helper.rb
|
202
203
|
homepage: http://miketheman.github.com/knife-community
|
203
204
|
licenses: []
|
@@ -219,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
220
|
version: '0'
|
220
221
|
segments:
|
221
222
|
- 0
|
222
|
-
hash: -
|
223
|
+
hash: -2471496466825284524
|
223
224
|
requirements: []
|
224
225
|
rubyforge_project:
|
225
226
|
rubygems_version: 1.8.25
|
@@ -230,4 +231,5 @@ summary: A Knife plugin to assist with deploying completed Chef cookbooks to the
|
|
230
231
|
test_files:
|
231
232
|
- features/cli.feature
|
232
233
|
- features/support/env.rb
|
234
|
+
- spec/community_spec.rb
|
233
235
|
- spec/spec_helper.rb
|