cookbook-release 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +13 -1
- data/cookbook-release.gemspec +1 -1
- data/lib/cookbook-release.rb +22 -0
- data/lib/cookbook-release/changelog.rb +44 -0
- data/lib/cookbook-release/commit.rb +28 -0
- data/lib/cookbook-release/git-utilities.rb +12 -13
- data/spec/changelog_spec.rb +20 -0
- data/spec/git_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzQ2NmZhNTI5ZDExYjU5MzUwNTdjMjMzZjVkOTc1NTM3NGMwNTkwYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODdkNzcxODc5MzAzNjljNTgzMjE2YWM5MWIwYjgyYzVjZDg5NDg3Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDgwMzJhZDlmZTU3NzU1MWQ2MDhkMThlNGM5NTY3N2ZiZjVmMDFhNjFmN2E1
|
10
|
+
ZDllNzg3NmVmMmIyMjJmN2E0N2UyNTcwYzAyOTIyYjgzOWJlZjAyYWNkMTE3
|
11
|
+
NzI3ZDlhMjMzZDNiZWY4ODFlZWNjMjQzODQ4N2FmNmE3ZGEzZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGJkMWM1YzMyMGM2YjdkMjFiYzlmNWJlYmRjNjI2ZTliNmMyZGQzYzdlOWU5
|
14
|
+
MGFhOWUxYzQ4ZTAzZmU4ZjNiOTVjYTJkOWExM2UwM2ZkNDFlMjI2MDBjZWY0
|
15
|
+
OGY1Y2M3YzM4OWQ0N2Y4MjdkMmZjZjNiNjI1Mzk1NDBiMWE5MDk=
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Examples of messages:
|
|
28
28
|
- Fix migration code for old centos versions
|
29
29
|
|
30
30
|
|
31
|
-
One-time setup
|
31
|
+
One-time setup (for cookbooks)
|
32
32
|
-----
|
33
33
|
|
34
34
|
Include cookbook-release into your `Gemfile`.
|
@@ -65,3 +65,15 @@ export COOKBOOK_CATEGORY="Other" # defaults to Other
|
|
65
65
|
```
|
66
66
|
|
67
67
|
Note: this setup is intended to be used in a CI system such as jenkins or travis.
|
68
|
+
|
69
|
+
|
70
|
+
Changelog generation for chef-repositories
|
71
|
+
----
|
72
|
+
|
73
|
+
Using:
|
74
|
+
```
|
75
|
+
require 'cookbook-release'
|
76
|
+
CookbookRelease::Rake::RepoTask.new
|
77
|
+
```
|
78
|
+
|
79
|
+
will allow to create tasks to generate html changelog between HEAD and master branch. It aims to make some changes more visible such as [Risky] tag (or any tag used for major changes).
|
data/cookbook-release.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'English'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'cookbook-release'
|
9
|
-
spec.version = '1.
|
9
|
+
spec.version = '1.1.0'
|
10
10
|
spec.authors = ['Grégoire Seux']
|
11
11
|
spec.email = 'g.seux@criteo.com'
|
12
12
|
spec.summary = 'Provide primitives (and rake tasks) to release a cookbook'
|
data/lib/cookbook-release.rb
CHANGED
@@ -2,12 +2,34 @@ require_relative 'cookbook-release/commit'
|
|
2
2
|
require_relative 'cookbook-release/git-utilities'
|
3
3
|
require_relative 'cookbook-release/supermarket'
|
4
4
|
require_relative 'cookbook-release/release'
|
5
|
+
require_relative 'cookbook-release/changelog'
|
5
6
|
|
6
7
|
require 'rake'
|
7
8
|
require 'rake/tasklib'
|
8
9
|
|
9
10
|
module CookbookRelease
|
10
11
|
module Rake
|
12
|
+
|
13
|
+
class RepoTask < ::Rake::TaskLib
|
14
|
+
def initialize(opts = {}, &html_block)
|
15
|
+
desc "Display raw changelog between branches"
|
16
|
+
task "changelog:raw" do
|
17
|
+
git = GitUtilities.new
|
18
|
+
puts Changelog.new(git, opts).raw
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Display html changelog between branches"
|
22
|
+
task "changelog:html" do
|
23
|
+
git = GitUtilities.new
|
24
|
+
html = Changelog.new(git, opts).html
|
25
|
+
if block_given?
|
26
|
+
html = html_block.call(html)
|
27
|
+
end
|
28
|
+
puts html
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
11
33
|
class CookbookTask < ::Rake::TaskLib
|
12
34
|
|
13
35
|
def initialize(namespaced=false)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module CookbookRelease
|
2
|
+
class Changelog
|
3
|
+
|
4
|
+
DEFAULT_OPTS = {
|
5
|
+
expand_major: true,
|
6
|
+
expand_risky: true,
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(git, opts = {})
|
10
|
+
@git = git
|
11
|
+
@opts = DEFAULT_OPTS.merge(opts)
|
12
|
+
end
|
13
|
+
|
14
|
+
def raw
|
15
|
+
changelog.map(&:to_s_oneline)
|
16
|
+
end
|
17
|
+
|
18
|
+
def html
|
19
|
+
result = []
|
20
|
+
result << <<-EOH
|
21
|
+
<html>
|
22
|
+
<body>
|
23
|
+
EOH
|
24
|
+
result << changelog.map do |c|
|
25
|
+
full_body ||= @opts[:expand_major] && c.major?
|
26
|
+
full_body ||= @opts[:expand_risky] && c.risky?
|
27
|
+
full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
|
28
|
+
c.to_s_html(full_body)
|
29
|
+
end.map { |c| " <p>#{c}</p>" }
|
30
|
+
result << <<-EOH
|
31
|
+
</body>
|
32
|
+
</html>
|
33
|
+
EOH
|
34
|
+
result.join("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def changelog
|
40
|
+
@git.compute_changelog('master')
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -30,14 +30,42 @@ module CookbookRelease
|
|
30
30
|
!(major? || patch?)
|
31
31
|
end
|
32
32
|
|
33
|
+
def risky?
|
34
|
+
!!(self[:subject] =~ /\[risky\]/i)
|
35
|
+
end
|
36
|
+
|
33
37
|
def color
|
34
38
|
case true
|
35
39
|
when major?
|
36
40
|
:red
|
41
|
+
when risky?
|
42
|
+
:red
|
37
43
|
else
|
38
44
|
:grey
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
48
|
+
def to_s_oneline
|
49
|
+
"#{self[:hash]} #{self[:author]} #{self[:subject]}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s_html(full)
|
53
|
+
result = []
|
54
|
+
result << <<-EOH
|
55
|
+
<font color=#{color.to_s}>
|
56
|
+
#{self[:hash]} #{self[:author]} #{self[:subject]}
|
57
|
+
</font>
|
58
|
+
EOH
|
59
|
+
if full && self[:body]
|
60
|
+
result << <<-EOH
|
61
|
+
<pre>
|
62
|
+
#{self[:body]}
|
63
|
+
</pre>
|
64
|
+
EOH
|
65
|
+
end
|
66
|
+
|
67
|
+
result.join("\n")
|
68
|
+
end
|
69
|
+
|
42
70
|
end
|
43
71
|
end
|
@@ -16,11 +16,7 @@ module CookbookRelease
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.git?(dir)
|
19
|
-
|
20
|
-
'git status',
|
21
|
-
cwd: dir,
|
22
|
-
environment: { GIT_DIR: dir }
|
23
|
-
).run_command.error?
|
19
|
+
File.directory?(::File.join(dir, '.git'))
|
24
20
|
end
|
25
21
|
|
26
22
|
def reset_command(new_version)
|
@@ -56,23 +52,26 @@ module CookbookRelease
|
|
56
52
|
last.to_version
|
57
53
|
end
|
58
54
|
|
59
|
-
#
|
55
|
+
# These string are used to split git commit summary
|
60
56
|
# it just needs to be unlikely in a commit message
|
61
|
-
MAGIC_SEP
|
57
|
+
MAGIC_SEP = '@+-+@+-+@+-+@'
|
58
|
+
MAGIC_COMMIT_SEP = '@===@===@===@'
|
62
59
|
|
63
60
|
def compute_changelog(since)
|
64
|
-
|
65
|
-
log_cmd = Mixlib::ShellOut.new("git log --pretty=\"format:%an <%ae>#{MAGIC_SEP}%s#{MAGIC_SEP}%h\" #{since}..HEAD", @shellout_opts)
|
61
|
+
log_cmd = Mixlib::ShellOut.new("git log --pretty=\"tformat:%an <%ae>#{MAGIC_SEP}%s#{MAGIC_SEP}%h#{MAGIC_SEP}%b#{MAGIC_COMMIT_SEP}\" #{since}..HEAD", @shellout_opts)
|
66
62
|
log_cmd.run_command
|
63
|
+
log_cmd.error!
|
67
64
|
log = log_cmd.stdout
|
68
|
-
log.split(
|
69
|
-
|
65
|
+
log.split(MAGIC_COMMIT_SEP).map do |entry|
|
66
|
+
next if entry.chomp == ''
|
67
|
+
author, subject, hash, body = entry.chomp.split(MAGIC_SEP)
|
70
68
|
Commit.new({
|
71
69
|
author: author,
|
72
70
|
subject: subject,
|
73
|
-
hash: hash
|
71
|
+
hash: hash,
|
72
|
+
body: body
|
74
73
|
})
|
75
|
-
end.reject { |commit| commit[:subject] =~ /^Merge branch (.*) into/i }
|
74
|
+
end.compact.reject { |commit| commit[:subject] =~ /^Merge branch (.*) into/i }
|
76
75
|
end
|
77
76
|
|
78
77
|
def tag(version)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe CookbookRelease::Changelog do
|
4
|
+
let(:git) do
|
5
|
+
double('git', :no_prompt= => true)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.html' do
|
9
|
+
|
10
|
+
it 'colorize Risky commits in red' do
|
11
|
+
expect(git).to receive(:compute_changelog).and_return([
|
12
|
+
CookbookRelease::Commit.new(hash: '654321', subject: '[Risky] hello', author: 'John Doe'),
|
13
|
+
CookbookRelease::Commit.new(hash: '123456', subject: 'hello', author: 'John Doe'),
|
14
|
+
])
|
15
|
+
changelog = CookbookRelease::Changelog.new(git)
|
16
|
+
expect(changelog.html).to match(/color=red((?!color=grey).)*Risky/m)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/git_spec.rb
CHANGED
@@ -103,7 +103,7 @@ describe CookbookRelease::GitUtilities do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
changelog = git.compute_changelog('1.0.0')
|
106
|
-
expect(changelog.size).to
|
106
|
+
expect(changelog.size).to eq(3)
|
107
107
|
expect(changelog.map {|c| c[:subject]}).to contain_exactly('A commit', 'Another commit', 'A third one')
|
108
108
|
end
|
109
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookbook-release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grégoire Seux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -136,10 +136,12 @@ files:
|
|
136
136
|
- Rakefile.rb
|
137
137
|
- cookbook-release.gemspec
|
138
138
|
- lib/cookbook-release.rb
|
139
|
+
- lib/cookbook-release/changelog.rb
|
139
140
|
- lib/cookbook-release/commit.rb
|
140
141
|
- lib/cookbook-release/git-utilities.rb
|
141
142
|
- lib/cookbook-release/release.rb
|
142
143
|
- lib/cookbook-release/supermarket.rb
|
144
|
+
- spec/changelog_spec.rb
|
143
145
|
- spec/commit_spec.rb
|
144
146
|
- spec/git_spec.rb
|
145
147
|
- spec/release_spec.rb
|
@@ -170,6 +172,7 @@ signing_key:
|
|
170
172
|
specification_version: 4
|
171
173
|
summary: Provide primitives (and rake tasks) to release a cookbook
|
172
174
|
test_files:
|
175
|
+
- spec/changelog_spec.rb
|
173
176
|
- spec/commit_spec.rb
|
174
177
|
- spec/git_spec.rb
|
175
178
|
- spec/release_spec.rb
|