cookbook-release 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cookbook-release.gemspec +1 -1
- data/lib/cookbook-release.rb +6 -0
- data/lib/cookbook-release/changelog.rb +27 -0
- data/lib/cookbook-release/commit.rb +4 -0
- data/lib/cookbook-release/git-utilities.rb +4 -1
- data/spec/changelog_spec.rb +35 -0
- data/spec/git_spec.rb +27 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d48e42c04f5d4ac5f465c53eebb18921398ba5212f39cf0fa6207e6377e3b162
|
4
|
+
data.tar.gz: 684da15c491938a19b473ddcd997d428830631c11a0a174b70dcf02bf1dbba9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a2455d339262c0e83172ee37af3ff81f224139915022a97dcbbbac2ea8d8b45e754af7dcf7a913c612418d63614848ce7c0fc6d957bddddb77cb01515f66eef
|
7
|
+
data.tar.gz: 4fd577bd939752c1ddf96d003f9c521b2c186b2e3ce9333046cfb1a0d5c2c3c8b0e2415d26aa4183955ed1ab0625559755e1b13cc783099224985cb3b4a2d528
|
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.4.
|
9
|
+
spec.version = '1.4.3'
|
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
@@ -56,6 +56,12 @@ module CookbookRelease
|
|
56
56
|
git = GitUtilities.new('sub_dir': args['sub_dir'])
|
57
57
|
puts Changelog.new(git, opts).markdown_priority
|
58
58
|
end
|
59
|
+
|
60
|
+
desc 'Display markdown changelog between branches with risky commits on top and non-node-only changes separated'
|
61
|
+
task 'changelog:markdown_priority_nodes', [:sub_dir] do |_, args|
|
62
|
+
git = GitUtilities.new('sub_dir': args['sub_dir'])
|
63
|
+
puts Changelog.new(git, opts).markdown_priority_nodes
|
64
|
+
end
|
59
65
|
end
|
60
66
|
end
|
61
67
|
|
@@ -4,11 +4,13 @@ module CookbookRelease
|
|
4
4
|
DEFAULT_OPTS = {
|
5
5
|
expand_major: true,
|
6
6
|
expand_risky: true,
|
7
|
+
separate_nodes: true,
|
7
8
|
short_sha: true
|
8
9
|
}
|
9
10
|
|
10
11
|
RISKY = 'RISKY/BREAKING (details below):'
|
11
12
|
NO_RISKY = 'NO RISKY/BREAKING COMMITS. READ FULL CHANGELOG.'
|
13
|
+
NON_NODES_ONLY = 'Non-risky/major, Non-node-only commits'
|
12
14
|
FULL = 'Full changelog:'
|
13
15
|
DETAILS = 'Details of risky commits:'
|
14
16
|
|
@@ -42,6 +44,7 @@ module CookbookRelease
|
|
42
44
|
result << changelog.map do |c|
|
43
45
|
full_body ||= @opts[:expand_major] && c.major?
|
44
46
|
full_body ||= @opts[:expand_risky] && c.risky?
|
47
|
+
full_body ||= @opts[:separate_nodes] && c.nodes_only?
|
45
48
|
full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
|
46
49
|
c.to_s_html(full_body)
|
47
50
|
end.map { |c| " <p>#{c}</p>" }
|
@@ -81,6 +84,8 @@ module CookbookRelease
|
|
81
84
|
changelog.map do |c|
|
82
85
|
full_body ||= @opts[:expand_major] && c.major?
|
83
86
|
full_body ||= @opts[:expand_risky] && c.risky?
|
87
|
+
full_body ||= @opts[:separate_nodes] && c.nodes_only?
|
88
|
+
full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
|
84
89
|
full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
|
85
90
|
c.to_s_markdown(full_body)
|
86
91
|
end.join("\n")
|
@@ -103,6 +108,28 @@ module CookbookRelease
|
|
103
108
|
result
|
104
109
|
end
|
105
110
|
|
111
|
+
def markdown_priority_nodes
|
112
|
+
cl = changelog
|
113
|
+
risky_commits = cl.select { |c| c.risky? || c.major? }
|
114
|
+
not_nodes_only_commits = cl.reject { |c| c.nodes_only? || c.risky? || c.major? }
|
115
|
+
result = []
|
116
|
+
if risky_commits.any?
|
117
|
+
result << "*#{RISKY}*\n" << risky_commits.map { |c| c.to_s_markdown(false) }.join("\n") << "\n"
|
118
|
+
else
|
119
|
+
result << "*#{NO_RISKY}*\n\n"
|
120
|
+
end
|
121
|
+
if not_nodes_only_commits.any?
|
122
|
+
result << "*#{NON_NODES_ONLY}*\n" << not_nodes_only_commits.map { |c| c.to_s_markdown(false) }.join("\n") << "\n"
|
123
|
+
end
|
124
|
+
result << "*#{FULL}*\n"
|
125
|
+
result << cl.map { |c| c.to_s_markdown(false) }.join("\n")
|
126
|
+
if risky_commits.any?
|
127
|
+
result << "\n#{DETAILS}\n"
|
128
|
+
result << risky_commits.map { |c| c.to_s_markdown(true) }.join("\n")
|
129
|
+
end
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
106
133
|
private
|
107
134
|
|
108
135
|
def changelog
|
@@ -72,7 +72,10 @@ module CookbookRelease
|
|
72
72
|
subject: message.delete_at(0),
|
73
73
|
hash: short_sha ? commit.sha[0,7] : commit.sha,
|
74
74
|
body: message.empty? ? nil : message.join("\n"),
|
75
|
-
is_merge_commit: commit.parents.length > 1
|
75
|
+
is_merge_commit: commit.parents.length > 1,
|
76
|
+
nodes_only: @g.diff(commit.sha, "#{commit.sha}~1").name_status.reject do |path, change_type|
|
77
|
+
path.include?('nodes/') && ['A', 'D'].include?(change_type) # basic node additions or deletions only
|
78
|
+
end.count.zero?
|
76
79
|
)
|
77
80
|
end.reject { |commit| commit[:is_merge_commit] }
|
78
81
|
end
|
data/spec/changelog_spec.rb
CHANGED
@@ -55,5 +55,40 @@ describe CookbookRelease::Changelog do
|
|
55
55
|
expect(changelog.markdown).to start_with('*654321* @j.doe `[Risky] hello`')
|
56
56
|
end
|
57
57
|
end
|
58
|
+
context 'Separates risky and non-risky+non-nodes' do
|
59
|
+
let(:commits) do
|
60
|
+
[
|
61
|
+
CookbookRelease::Commit.new(
|
62
|
+
hash: '654321',
|
63
|
+
subject: 'hello',
|
64
|
+
author: 'John Doe',
|
65
|
+
email: 'j.doe@nobody.com',
|
66
|
+
body: 'New Men Just Want to Watch the World Burn',
|
67
|
+
nodes_only: false),
|
68
|
+
CookbookRelease::Commit.new(
|
69
|
+
hash: '654321',
|
70
|
+
subject: '[Risky] hello',
|
71
|
+
author: 'John Doe',
|
72
|
+
email: 'j.doe@nobody.com',
|
73
|
+
body: 'Some Men Just Want to Watch the World Turn',
|
74
|
+
nodes_only: true),
|
75
|
+
CookbookRelease::Commit.new(
|
76
|
+
hash: '654321',
|
77
|
+
subject: 'hello only nodes',
|
78
|
+
author: 'John Doe',
|
79
|
+
email: 'j.doe@nobody.com',
|
80
|
+
body: 'Old Men Just Want to Watch the World Learn',
|
81
|
+
nodes_only: true)
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'expands the body with non-risky+non-nodes' do
|
86
|
+
expect(git).to receive(:compute_changelog).and_return(commits)
|
87
|
+
changelog = CookbookRelease::Changelog.new(git, expand_risky: true, nodes_only: true)
|
88
|
+
expect(changelog.markdown_priority_nodes.join('')).to include(
|
89
|
+
"\n*Non-risky/major, Non-node-only commits*\n*654321* _John Doe <j.doe@nobody.com>_ `hello`\n*Full"
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
58
93
|
end
|
59
94
|
end
|
data/spec/git_spec.rb
CHANGED
@@ -183,5 +183,32 @@ git tag 12.34.56
|
|
183
183
|
changelog = git.compute_changelog('HEAD~1', false)
|
184
184
|
expect(changelog[0][:hash].size).to eq(40)
|
185
185
|
end
|
186
|
+
|
187
|
+
it 'detects node-only commits' do
|
188
|
+
cmds = <<-EOH
|
189
|
+
mkdir -p nodes/preprod
|
190
|
+
echo "hello first" > nodes/preprod/tata.rb
|
191
|
+
git add nodes/preprod/tata.rb
|
192
|
+
git commit -m "hello there"
|
193
|
+
echo "hello second" > nodes/preprod/tata.rb
|
194
|
+
git add nodes/preprod/tata.rb
|
195
|
+
git commit -m "hello there modify"
|
196
|
+
mkdir -p toto
|
197
|
+
echo "hello" > toto/titi.rb
|
198
|
+
git add toto/titi.rb
|
199
|
+
git commit -m "subject" -m "body" -m "line2"
|
200
|
+
EOH
|
201
|
+
cmds.split("\n").each do |cmd|
|
202
|
+
cmd = Mixlib::ShellOut.new(cmd)
|
203
|
+
cmd.run_command
|
204
|
+
cmd.error!
|
205
|
+
end
|
206
|
+
|
207
|
+
git = CookbookRelease::GitUtilities.new
|
208
|
+
changelog = git.compute_changelog('HEAD~3')
|
209
|
+
expect(changelog[0][:nodes_only]).to be false # Add a non-"nodes" file
|
210
|
+
expect(changelog[1][:nodes_only]).to be false # Modify a "nodes" file
|
211
|
+
expect(changelog[2][:nodes_only]).to be true # Add a "nodes" file
|
212
|
+
end
|
186
213
|
end
|
187
214
|
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.
|
4
|
+
version: 1.4.3
|
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:
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.7.
|
184
|
+
rubygems_version: 2.7.6
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: Provide primitives (and rake tasks) to release a cookbook
|