emeril 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +25 -13
- data/CHANGELOG.md +16 -0
- data/Gemfile +9 -0
- data/Guardfile +20 -7
- data/README.md +29 -16
- data/Rakefile +15 -10
- data/emeril.gemspec +23 -20
- data/lib/emeril.rb +6 -6
- data/lib/emeril/category.rb +9 -5
- data/lib/emeril/git_tagger.rb +16 -12
- data/lib/emeril/logging.rb +1 -1
- data/lib/emeril/metadata_chopper.rb +8 -8
- data/lib/emeril/publisher.rb +13 -12
- data/lib/emeril/rake.rb +1 -1
- data/lib/emeril/rake_tasks.rb +4 -4
- data/lib/emeril/releaser.rb +18 -10
- data/lib/emeril/thor.rb +1 -1
- data/lib/emeril/thor_tasks.rb +3 -3
- data/lib/emeril/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/known_cookbook.yml +28 -23
- data/spec/fixtures/vcr_cassettes/new_release.yml +83 -63
- data/spec/fixtures/vcr_cassettes/nonexistant_cookbook.yml +28 -16
- data/spec/integration/new_release_spec.rb +15 -12
- data/spec/integration/skip_publish_spec.rb +22 -14
- data/spec/spec_helper.rb +56 -37
- data/spec/unit/emeril/category_spec.rb +9 -8
- data/spec/unit/emeril/git_tagger_spec.rb +7 -7
- data/spec/unit/emeril/metadata_chopper_spec.rb +3 -3
- data/spec/unit/emeril/publisher_spec.rb +15 -15
- data/spec/unit/emeril/releaser_spec.rb +44 -13
- metadata +43 -70
- data/.tailor +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea38c2a413453dc993a0f7c379b00e67755630eb
|
4
|
+
data.tar.gz: dac57f07727c206a5f4a1dd717282b0340fec835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f720829a5ceda4b62888507ff8e0ca3e0aa74a6490e3fae7e0708c34893756f2ac22ad73322b6ea0e172b94ec66fed495af3ddc6038c5bfe613168c8264483a
|
7
|
+
data.tar.gz: e3af47e245b8334ba4c0ba6aba34009766b0bea2183e5ecdcea4879be52c0cfc1f4d4464e135a79bed108f4d93454d9f131f2c2fd481f6155ce04d2235c78be3
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,22 +1,34 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
-
|
6
|
-
- 1.9.
|
7
|
-
-
|
4
|
+
- 2.1
|
5
|
+
- 2.0.0
|
6
|
+
- 1.9.3
|
7
|
+
- 1.9.2
|
8
|
+
- ruby-head
|
8
9
|
|
9
10
|
env:
|
10
|
-
- "CHEF_VERSION="
|
11
|
-
- "CHEF_VERSION='~> 11.
|
12
|
-
- "CHEF_VERSION='~> 11.4.4'"
|
13
|
-
- "CHEF_VERSION='~> 10.26'"
|
11
|
+
- "CHEF_VERSION="
|
12
|
+
- "CHEF_VERSION='~> 11.14.2'"
|
13
|
+
- "CHEF_VERSION='~> 11.4.4'"
|
14
|
+
- "CHEF_VERSION='~> 10.26'"
|
15
|
+
|
16
|
+
bundler_args: --without guard
|
14
17
|
|
15
18
|
matrix:
|
16
19
|
allow_failures:
|
17
|
-
|
20
|
+
- rvm: ruby-head
|
18
21
|
exclude:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
- rvm: 2.1
|
23
|
+
env: "CHEF_VERSION='~> 11.4.4'"
|
24
|
+
- rvm: 2.1
|
25
|
+
env: "CHEF_VERSION='~> 10.26'"
|
26
|
+
- rvm: 2.0.0
|
27
|
+
env: "CHEF_VERSION='~> 11.4.4'"
|
28
|
+
- rvm: 2.0.0
|
29
|
+
env: "CHEF_VERSION='~> 10.26'"
|
30
|
+
|
31
|
+
addons:
|
32
|
+
code_climate:
|
33
|
+
repo_token:
|
34
|
+
secure: "Apwuy7PdnWsOjQqkVYIfZQIcECns0D+eNecRmG0dQguBbgnQfG9xMMGIwuLshubhs9rPqAac/Bg9ZyIjWBa57V/ehaQg7BTzaN8K76R98lgrQ4Ub3bYoCU91zc554g4sgKMf5K8P5f1NLYGEyDb5+QP4oeafF1UDxwVHL17hHq0="
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 0.8.0 / 2014-08-06
|
2
|
+
|
3
|
+
### Bug fixes
|
4
|
+
|
5
|
+
* Pull request [#4][]: Support Chef 11.6.2. ([@webframp][])
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Pull request [#6][]: Add Supermarket friendliness (it previously worked fine, but now is directly using Supermarket). ([@fnichol][])
|
10
|
+
* Pull request [#5][]: Update testing and project health dependencies and coding style. ([@fnichol][])
|
11
|
+
|
12
|
+
|
1
13
|
## 0.7.0 / 2013-08-26
|
2
14
|
|
3
15
|
### Breaking Changes
|
@@ -38,6 +50,10 @@ The initial release, **BAM**!
|
|
38
50
|
<!--- The following link definition list is generated by PimpMyChangelog --->
|
39
51
|
[#1]: https://github.com/fnichol/emeril/issues/1
|
40
52
|
[#2]: https://github.com/fnichol/emeril/issues/2
|
53
|
+
[#4]: https://github.com/fnichol/emeril/issues/4
|
54
|
+
[#5]: https://github.com/fnichol/emeril/issues/5
|
55
|
+
[#6]: https://github.com/fnichol/emeril/issues/6
|
41
56
|
[@capen]: https://github.com/capen
|
42
57
|
[@fnichol]: https://github.com/fnichol
|
43
58
|
[@thbishop]: https://github.com/thbishop
|
59
|
+
[@webframp]: https://github.com/webframp
|
data/Gemfile
CHANGED
@@ -2,7 +2,16 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
group :guard do
|
6
|
+
gem 'guard-minitest'
|
7
|
+
gem 'guard-rubocop'
|
8
|
+
gem 'guard-cane'
|
9
|
+
gem 'guard-yard'
|
10
|
+
end
|
11
|
+
|
5
12
|
group :test do
|
6
13
|
# allow CI to override the version of Chef for matrix testing
|
7
14
|
gem 'chef', (ENV['CHEF_VERSION'] || '>= 0.10.10')
|
15
|
+
|
16
|
+
gem 'codeclimate-test-reporter', require: nil
|
8
17
|
end
|
data/Guardfile
CHANGED
@@ -1,10 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
ignore %r{^\.gem/}
|
2
|
+
|
3
|
+
group :red_green_refactor, halt_on_fail: true do
|
4
|
+
guard :minitest do
|
5
|
+
watch(%r|^spec/(.*)_spec\.rb|)
|
6
|
+
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/unit/#{m[1]}#{m[2]}_spec.rb" }
|
7
|
+
watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
8
|
+
end
|
9
|
+
|
10
|
+
guard :cane do
|
11
|
+
watch(%r|.*\.rb|)
|
12
|
+
watch('.cane')
|
13
|
+
end
|
14
|
+
|
15
|
+
guard :rubocop, all_on_start: false, keep_failed: false, cli: "-r finstyle" do
|
16
|
+
watch(%r{.+\.rb$})
|
17
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
18
|
+
end
|
5
19
|
end
|
6
20
|
|
7
|
-
guard
|
8
|
-
watch(%r
|
9
|
-
watch('.cane')
|
21
|
+
guard :yard, port: "8808" do
|
22
|
+
watch(%r{lib/.+\.rb})
|
10
23
|
end
|
data/README.md
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/emeril.png)](http://badge.fury.io/rb/emeril)
|
4
4
|
[![Build Status](https://travis-ci.org/fnichol/emeril.png?branch=master)](https://travis-ci.org/fnichol/emeril)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/fnichol/emeril.png)](https://codeclimate.com/github/fnichol/emeril)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/fnichol/emeril/badges/coverage.svg)](https://codeclimate.com/github/fnichol/emeril)
|
6
7
|
[![Dependency Status](https://gemnasium.com/fnichol/emeril.png)](https://gemnasium.com/fnichol/emeril)
|
8
|
+
[![Inline docs](http://inch-ci.org/github/fnichol/emeril.png?branch=master)](http://inch-ci.org/github/fnichol/emeril)
|
7
9
|
|
8
10
|
Kick it up a notch! Emeril is a library that helps you release your Chef
|
9
11
|
cookbooks from Rake, Thor, or a Ruby library. If `rake release` is all you
|
@@ -27,7 +29,7 @@ Need more details? Read on…
|
|
27
29
|
## <a name="screencast"></a> Screencast
|
28
30
|
|
29
31
|
Here is a short screencast demonstating how Emeril can be used to release
|
30
|
-
a cookbook to the
|
32
|
+
a cookbook to the Supermarket site.
|
31
33
|
|
32
34
|
[![Emeril screencast](https://raw.github.com/fnichol/emeril/master/images/emeril-vid.png)](http://vimeo.com/fnichol/emeril)
|
33
35
|
|
@@ -38,7 +40,7 @@ Emeril has 2 primary tasks and goals:
|
|
38
40
|
1. Tag a Git commit with a semantic version tag with the form `"v1.2.5"` (by
|
39
41
|
default)
|
40
42
|
2. Optionally publish a versioned release of the cookbook to the
|
41
|
-
[
|
43
|
+
[Supermarket site][supermarket_site]
|
42
44
|
|
43
45
|
The Git tagging is currently accomplished via shell out, so Git must be
|
44
46
|
installed on your system.
|
@@ -95,9 +97,9 @@ file with some required attributes set.
|
|
95
97
|
|
96
98
|
There are 2 configuration items you need:
|
97
99
|
|
98
|
-
1. Your [
|
99
|
-
2. The file path to your [
|
100
|
-
When you sign up to the
|
100
|
+
1. Your [Supermarket site][supermarket_site] username, chosen at signup time.
|
101
|
+
2. The file path to your [Supermarket site][supermarket_site] user certificate.
|
102
|
+
When you sign up to the Supermarket site, the site will provide this key to
|
101
103
|
you as a `*.pem` file.
|
102
104
|
|
103
105
|
The easiest way to get setup is to add both of these items to your default
|
@@ -140,14 +142,14 @@ Emeril::RakeTasks.new do |t|
|
|
140
142
|
end
|
141
143
|
```
|
142
144
|
|
143
|
-
If your cookbook is not on the
|
144
|
-
with the block form:
|
145
|
+
If your cookbook is not on the Supermarket site, you can skip the publishing
|
146
|
+
step with the block form:
|
145
147
|
|
146
148
|
```ruby
|
147
149
|
require 'emeril/rake_tasks'
|
148
150
|
|
149
151
|
Emeril::RakeTasks.new do |t|
|
150
|
-
t.config[:
|
152
|
+
t.config[:publish_to_supermarket] = false
|
151
153
|
end
|
152
154
|
```
|
153
155
|
|
@@ -178,14 +180,14 @@ Emeril::ThorTasks.new do |t|
|
|
178
180
|
end
|
179
181
|
```
|
180
182
|
|
181
|
-
If your cookbook is not on the
|
182
|
-
with the block form:
|
183
|
+
If your cookbook is not on the Supermarket site, you can skip the publishing
|
184
|
+
step with the block form:
|
183
185
|
|
184
186
|
```ruby
|
185
187
|
require 'emeril/thor_tasks'
|
186
188
|
|
187
189
|
Emeril::ThorTasks.new do |t|
|
188
|
-
t.config[:
|
190
|
+
t.config[:publish_to_supermarket] = false
|
189
191
|
end
|
190
192
|
```
|
191
193
|
|
@@ -203,7 +205,7 @@ same code as the default Rake and Thor tasks, use the following:
|
|
203
205
|
require 'chef/knife'
|
204
206
|
Chef::Knife.new.configure_chef
|
205
207
|
|
206
|
-
# Perform the git tagging and share to the
|
208
|
+
# Perform the git tagging and share to the Supermarket site
|
207
209
|
require 'emeril'
|
208
210
|
Emeril::Releaser.new(logger: Chef::Log).run
|
209
211
|
```
|
@@ -225,10 +227,17 @@ Emeril::Releaser.new(logger: Chef::Log).run
|
|
225
227
|
[commit][ex3]. Emeril will tag and release your cookbook based on the
|
226
228
|
last Git commit which is presumably your *version-bump-and-changelog*
|
227
229
|
commit.
|
230
|
+
* **"What about adding support for X, Y, or Z?"** That's possible, but Emeril
|
231
|
+
has one primary focus: releasing your cookbook in an atomic and declarative
|
232
|
+
fashion. We can get the job done with a small amount of code--less than 400
|
233
|
+
LOC. There are other tools that are more wholistic and workflow oriented
|
234
|
+
and you are encouraged to check them out (noted below).
|
235
|
+
* **"That Chef dependency looks bulky, yo."** Hmm, that's not a question. Do
|
236
|
+
you you Knife? Congratulations, you have the Chef gem already! Are you using
|
237
|
+
the ChefDK package? You are good to go!
|
228
238
|
* **"How do I change the category for my cookbook?"** Emeril will maintain
|
229
|
-
the category used on the
|
230
|
-
cookbooks will be put in the `"Other"` category.
|
231
|
-
the category directly on the Community Site, done! Otherwise, check out
|
239
|
+
the category used on the Supermarket site across releases. By default, new
|
240
|
+
cookbooks will be put in the `"Other"` category. Otherwise, check out
|
232
241
|
the [Rake](#usage-rake) and [Thor](#usage-thor) sections for further
|
233
242
|
configuration help.
|
234
243
|
* **"Why is Emeril complaining that I'm missing the name attribute in my
|
@@ -245,6 +254,9 @@ Emeril::Releaser.new(logger: Chef::Log).run
|
|
245
254
|
* [knife community site share][knife_share] - with some extra/manual git
|
246
255
|
tagging, correct directory structure, and workflow. Ships with the
|
247
256
|
[Chef gem][chef_gem].
|
257
|
+
* [Stove][stove] - a more workflow oriented with JIRA and GitHub
|
258
|
+
support, version bumping, and more by
|
259
|
+
[Seth Vargo](https://github.com/sethvargo).
|
248
260
|
|
249
261
|
## <a name="development"></a> Development
|
250
262
|
|
@@ -278,7 +290,7 @@ MIT (see [LICENSE.txt][license])
|
|
278
290
|
[berkshelf_site]: http://berkshelf.com/
|
279
291
|
[changelog_wikipedia]: http://en.wikipedia.org/wiki/Changelog
|
280
292
|
[chef_gem]: https://github.com/opscode/chef
|
281
|
-
[
|
293
|
+
[supermarket_site]: https://supermarket.getchef.com/
|
282
294
|
[ex1]: https://github.com/fnichol/chef-ruby_build/commit/c940b5e9cd40eaba10d6285de6648f4d25fe959d
|
283
295
|
[ex2]: https://github.com/fnichol/chef-homesick/commit/80e558ff921f1c59698f6942214c0224a24392d7
|
284
296
|
[ex3]: https://github.com/fnichol/chef-openoffice/commit/bf84aba0690a6b155b499b06df953be19a3aead1
|
@@ -290,3 +302,4 @@ MIT (see [LICENSE.txt][license])
|
|
290
302
|
[knife_share]: http://docs.opscode.com/knife_cookbook_site.html#share
|
291
303
|
[publisher_class]: https://github.com/fnichol/emeril/blob/master/lib/emeril/publisher.rb
|
292
304
|
[semver_site]: http://semver.org/
|
305
|
+
[stove]: http://sethvargo.github.io/stove/
|
data/Rakefile
CHANGED
@@ -1,30 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "cane/rake_task"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:unit) do |t|
|
7
8
|
t.libs.push "lib"
|
8
|
-
t.test_files = FileList[
|
9
|
+
t.test_files = FileList["spec/unit/**/*_spec.rb"]
|
9
10
|
t.verbose = true
|
10
11
|
end
|
11
12
|
|
12
13
|
Rake::TestTask.new(:integration) do |t|
|
13
14
|
t.libs.push "lib"
|
14
|
-
t.test_files = FileList[
|
15
|
+
t.test_files = FileList["spec/integration/**/*_spec.rb"]
|
15
16
|
t.verbose = true
|
16
17
|
end
|
17
18
|
|
18
19
|
desc "Run all test suites"
|
19
20
|
task :test => [:unit, :integration]
|
20
21
|
|
22
|
+
require "finstyle"
|
23
|
+
require "rubocop/rake_task"
|
24
|
+
RuboCop::RakeTask.new(:style) do |task|
|
25
|
+
task.options << "--display-cop-names"
|
26
|
+
end
|
27
|
+
|
21
28
|
desc "Run cane to check quality metrics"
|
22
29
|
Cane::RakeTask.new do |cane|
|
23
|
-
cane.canefile =
|
30
|
+
cane.canefile = "./.cane"
|
24
31
|
end
|
25
32
|
|
26
|
-
Tailor::RakeTask.new
|
27
|
-
|
28
33
|
desc "Display LOC stats"
|
29
34
|
task :stats do
|
30
35
|
puts "\n## Production Code Stats"
|
@@ -34,6 +39,6 @@ task :stats do
|
|
34
39
|
end
|
35
40
|
|
36
41
|
desc "Run all quality tasks"
|
37
|
-
task :quality => [:cane, :
|
42
|
+
task :quality => [:cane, :style, :stats]
|
38
43
|
|
39
44
|
task :default => [:test, :quality]
|
data/emeril.gemspec
CHANGED
@@ -1,39 +1,42 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "emeril/version"
|
5
|
+
require "English"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "emeril"
|
8
9
|
spec.version = Emeril::VERSION
|
9
10
|
spec.authors = ["Fletcher Nichol"]
|
10
11
|
spec.email = ["fnichol@nichol.ca"]
|
11
|
-
spec.description =
|
12
|
+
spec.description = "Release Chef cookbooks"
|
12
13
|
spec.summary = spec.description
|
13
|
-
spec.homepage = "
|
14
|
+
spec.homepage = "http://fnichol.github.io/emeril/"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
18
|
spec.executables = []
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.required_ruby_version =
|
22
|
+
spec.required_ruby_version = ">= 1.9.2"
|
22
23
|
|
23
|
-
spec.add_dependency
|
24
|
+
spec.add_dependency "chef", "> 0.10.10"
|
24
25
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency 'webmock'
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "mocha"
|
30
|
+
spec.add_development_dependency "fakefs"
|
31
|
+
spec.add_development_dependency "vcr"
|
32
|
+
spec.add_development_dependency "webmock"
|
33
33
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
spec.add_development_dependency "simplecov"
|
35
|
+
spec.add_development_dependency "countloc"
|
36
|
+
|
37
|
+
# style and complexity libraries are tightly version pinned as newer releases
|
38
|
+
# may introduce new and undesireable style choices which would be immediately
|
39
|
+
# enforced in CI
|
40
|
+
spec.add_development_dependency "finstyle", "1.1.0"
|
41
|
+
spec.add_development_dependency "cane", "2.6.2"
|
39
42
|
end
|
data/lib/emeril.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "emeril/category"
|
4
|
+
require "emeril/git_tagger"
|
5
|
+
require "emeril/metadata_chopper"
|
6
|
+
require "emeril/publisher"
|
7
|
+
require "emeril/releaser"
|
8
|
+
require "emeril/version"
|
9
9
|
|
10
10
|
module Emeril
|
11
11
|
end
|
data/lib/emeril/category.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "net/https"
|
4
|
+
require "json"
|
5
|
+
require "uri"
|
5
6
|
|
6
7
|
module Emeril
|
7
8
|
|
@@ -18,9 +19,12 @@ module Emeril
|
|
18
19
|
# on the Community site
|
19
20
|
#
|
20
21
|
def self.for_cookbook(cookbook)
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
uri = URI("https://supermarket.getchef.com/api/v1/cookbooks/#{cookbook}")
|
23
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
24
|
+
http.use_ssl = true
|
25
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
26
|
+
response = http.request(request)
|
27
|
+
JSON.parse(response.body)["category"]
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/emeril/git_tagger.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
3
|
+
require "English"
|
4
|
+
|
5
|
+
require "emeril/logging"
|
4
6
|
|
5
7
|
module Emeril
|
6
8
|
|
7
9
|
# Exception class raised when a git repo is not clean.
|
8
10
|
#
|
9
|
-
class GitNotCleanError < StandardError
|
11
|
+
class GitNotCleanError < StandardError; end
|
10
12
|
|
11
13
|
# Exception class raised when a git push does not return successfully.
|
12
14
|
#
|
13
|
-
class GitPushError < StandardError
|
15
|
+
class GitPushError < StandardError; end
|
14
16
|
|
15
17
|
# Applies a version tag on a git repository and pushes it to the origin
|
16
18
|
# remote.
|
@@ -61,7 +63,7 @@ module Emeril
|
|
61
63
|
attr_reader :logger, :source_path, :tag_prefix, :version
|
62
64
|
|
63
65
|
def already_tagged?
|
64
|
-
if sh_with_code(
|
66
|
+
if sh_with_code("git tag")[0].split(/\n/).include?(version_tag)
|
65
67
|
info("Tag #{version_tag} has already been created.")
|
66
68
|
true
|
67
69
|
end
|
@@ -73,36 +75,38 @@ module Emeril
|
|
73
75
|
|
74
76
|
def git_push
|
75
77
|
perform_git_push
|
76
|
-
perform_git_push
|
78
|
+
perform_git_push " --tags"
|
77
79
|
info("Pushed git commits and tags.")
|
78
80
|
end
|
79
81
|
|
80
82
|
def guard_clean
|
81
|
-
clean?
|
82
|
-
|
83
|
+
if !clean?
|
84
|
+
raise GitNotCleanError,
|
85
|
+
"There are files that need to be committed first."
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
|
-
def perform_git_push(options =
|
89
|
+
def perform_git_push(options = "")
|
86
90
|
cmd = "git push origin master #{options}"
|
87
91
|
out, code = sh_with_code(cmd)
|
88
92
|
if code != 0
|
89
93
|
raise GitPushError,
|
90
|
-
"Couldn't git push. `#{cmd}' failed with the following output:"
|
94
|
+
"Couldn't git push. `#{cmd}' failed with the following output:" \
|
91
95
|
"\n\n#{out}\n"
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
95
99
|
def sh_with_code(cmd, &block)
|
96
100
|
cmd << " 2>&1"
|
97
|
-
outbuf =
|
101
|
+
outbuf = ""
|
98
102
|
debug(cmd)
|
99
103
|
Dir.chdir(source_path) {
|
100
104
|
outbuf = `#{cmd}`
|
101
|
-
if
|
105
|
+
if $CHILD_STATUS == 0
|
102
106
|
block.call(outbuf) if block
|
103
107
|
end
|
104
108
|
}
|
105
|
-
[outbuf,
|
109
|
+
[outbuf, $CHILD_STATUS]
|
106
110
|
end
|
107
111
|
|
108
112
|
def tag_version
|