cookbook-release 1.3.4 → 1.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ef411df78e2425fbcb6f48fab32e57bcbebacabc
4
- data.tar.gz: 91665c7ad89ba2fa63a8f586298214edbe8efc91
2
+ SHA256:
3
+ metadata.gz: 1d320d81b00bbc0568db5a101bf05cb341ffc23aed196a0d82a08a37c2921ccd
4
+ data.tar.gz: a66c146cce4f56369b30329f810d0de829abe85fcfe79f9760d0f445547d3a65
5
5
  SHA512:
6
- metadata.gz: 4fa616dc27a0e09e72c1ce1a4c85dc9462ccfedaa771e36267ef3013434da2b8b347ecce296af6c6d340e7ff5eefcb46da9f5e784ec9c469b57ea85aeb825b80
7
- data.tar.gz: 95fdeae091d01fb3db067cf525cc7beb3cc1c55c2cf0517b360b2e719549dd0be950f703ba063f550e911db795693129ed4ac8f263cff0c8df0e228533a30dd7
6
+ metadata.gz: a8d578db88940e2a0552cd74a203e104693ec1377b97db12fbf29ea15aed8e58e1fb1e967bc3226a8fb45a5689c24ab69d7826fd96a6935fdfc9d908b38f540d
7
+ data.tar.gz: febc04990a5974dd9305874332443155069f3f044d562fb5297b805345554b2ba62bac2b2e389bbde73bf396b1ef49b2caceddde7ec21b3501d4202d11aed7c7
@@ -4,8 +4,9 @@ rvm:
4
4
  deploy:
5
5
  provider: rubygems
6
6
  api_key:
7
- secure: nrEzm2dqWjyaa5ewApSonF+2D+y3PYwt9xaQC04d1NtbhQYyzX6wti3oatpMJI2gkcuuLjKrNHH/aLbKOGv7+Jj5BUJGOLixxhRdJyLWde/6cKCYVgIYPxeUtSJrRgyHAS2o8TDPjhWCT5oRwSkmhd+5D2JKjVqAycetbIzKWWvqScO09z0bF66bbKSfO1s44JwKjnUUW7W9tzrPvMPouBBoFtQ+dQVgxYLajgmjprVvIwzlHxgq/zP8YwL8i7vyRJFiQXyveSxZfBagN2qrUM72HWBPLLW4AeAdLDHYWon88GDU0p+cy2mVeSe67fBPVDopAEGij7MNJCBWV1/SRRKQcEb2U823+1GSB13OvaOGTn9rYsJP5zLKu77ATbHPi22nMfWOAzdEJJ+uFu9XW4nwUO/j79zPC1mEsRZDJlDrmTc4XZQJRKkCUjSl/J53vbdy4JQfos8B2V15tzx1baswQVPZuNiwuP4dOupI34FohJSVXQrsOoWVWVEX5Tfod6s3kpivW6lzwM68I2qXFa/4H8RPU2m0eVpfQslOO8TaGnbodudbQ1LSi/d5W6XWrMVqWGH910JG3jlJgHn5J7yQlI4VqnOpCjGsx/5xincuJZ7hBhcu5q5zcAGem7TrYSNkrx6neBYKmpZBHOWalIGw8wI9uViEsGQ6fayFee8=
7
+ secure: ylfB0GIaZxPfZ6/dSJIPujfSt3vxqVFg16lqTBq/2AAZ0qwKTZi9qeM/QZDLMX28vCXmTsYxHGepmyvv0PvJaKvy7E6YBzIKz1Y1vsEZFeAFrgIQq9cDvc4wIX2eFjI7N1ChyaRgi+YYK4BSVfKjYqGBfXk5Wyh7uqNEuWE7FzABV+RxXoHcNi+AhYkCX3NF80qNukXRtiB7XTQj6CP4Wd+Dm25iOUwx8/zNMce8Z8V3j2ysvR4Vtm/soDsr/+Z+27wIdP0VqwElV1FxtR9km8MIJhmzSsnzcvgqJpRmMvO6HLZFzwqnLBzCoPYJqm3K+uQSSfll5LbaNtixlBzIusgtGgm1UjQy1YDGkPexJd5K5CuC/LW78Y7Zrl3CeT34RDlICoztEjhJxFry3EvFxPT03lVQx5z5Fc55/u0hy3mBCiHbxHxAPJLMOtehfv35bzOS7Jv3+otBm/8jn9dXO2pJJdwxL9W2wrzljWkly4yemwceMvtMYf+xnf1zdTnMYoqkYGGl0KutbFL69w78w7BwTFQIhcJOO+g27C6V8vHtqU0U5JOgE/QNg3yWhzhQjgCpzQhmuO+Bcs3Jq2T/OcqTfwM6gufNe+Gq2TdEfeH5Y0WcRtTKJBVVQ4XWFtgONE1C1hNBFLyh7GNZDQQVYBT3c/MXeV5Q++rVJYOdSrw=
8
8
  gem: cookbook-release
9
9
  on:
10
10
  tags: true
11
11
  repo: criteo/cookbook-release
12
+ skip_cleanup: 'true'
data/README.md CHANGED
@@ -77,4 +77,4 @@ require 'cookbook-release'
77
77
  CookbookRelease::Rake::RepoTask.new
78
78
  ```
79
79
 
80
- 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).
80
+ 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). You may add a `sub_dir` parameter to restrict the scope of the changes to a sub-directory of the git root.
@@ -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.3.4'
9
+ spec.version = '1.4.5'
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'
@@ -22,8 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'semantic'
23
23
  spec.add_dependency 'highline'
24
24
  spec.add_dependency 'mixlib-shellout'
25
- spec.add_dependency 'chef'
25
+ spec.add_dependency 'chef', '>= 12.18.31'
26
26
  spec.add_dependency 'git-ng' # see https://github.com/schacon/ruby-git/issues/307
27
+ spec.add_dependency 'unicode-emoji'
27
28
 
28
29
 
29
30
  spec.add_development_dependency 'rspec'
@@ -12,15 +12,22 @@ module CookbookRelease
12
12
 
13
13
  class RepoTask < ::Rake::TaskLib
14
14
  def initialize(opts = {}, &html_block)
15
- desc "Display raw changelog between branches"
16
- task "changelog:raw" do
17
- git = GitUtilities.new
15
+ desc 'Display raw changelog between branches'
16
+ task 'changelog:raw', [:sub_dir] do |_, args|
17
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
18
18
  puts Changelog.new(git, opts).raw
19
19
  end
20
20
 
21
- desc "Display html changelog between branches"
22
- task "changelog:html" do
23
- git = GitUtilities.new
21
+ desc 'Display raw changelog between branches with risky commits on top'
22
+ task 'changelog:raw_priority', [:sub_dir] do |_, args|
23
+ git = GitUtilities.new(args)
24
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
25
+ puts Changelog.new(git, opts).raw_priority
26
+ end
27
+
28
+ desc 'Display html changelog between branches'
29
+ task 'changelog:html', [:sub_dir] do |_, args|
30
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
24
31
  html = Changelog.new(git, opts).html
25
32
  if block_given?
26
33
  html = html_block.call(html)
@@ -28,11 +35,33 @@ module CookbookRelease
28
35
  puts html
29
36
  end
30
37
 
38
+ desc 'Display html changelog between branches with risky commits on top'
39
+ task 'changelog:html_priority', [:sub_dir] do |_, args|
40
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
41
+ html = Changelog.new(git, opts).html_priority
42
+ if block_given?
43
+ html = html_block.call(html)
44
+ end
45
+ puts html
46
+ end
47
+
31
48
  desc 'Display markdown changelog between branches'
32
- task 'changelog:markdown' do
33
- git = GitUtilities.new
49
+ task 'changelog:markdown', [:sub_dir] do |_, args|
50
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
34
51
  puts Changelog.new(git, opts).markdown
35
52
  end
53
+
54
+ desc 'Display markdown changelog between branches with risky commits on top'
55
+ task 'changelog:markdown_priority', [:sub_dir] do |_, args|
56
+ git = GitUtilities.new('sub_dir': args['sub_dir'])
57
+ puts Changelog.new(git, opts).markdown_priority
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
36
65
  end
37
66
  end
38
67
 
@@ -44,8 +73,8 @@ module CookbookRelease
44
73
 
45
74
  def define_tasks(namespaced)
46
75
 
47
- desc "Prepare cookbook release and push tag to git"
48
- task "release!" do
76
+ desc 'Prepare cookbook release and push tag to git'
77
+ task 'release!' do
49
78
  opts = {
50
79
  no_prompt: ENV['NO_PROMPT'],
51
80
  category: ENV['COOKBOOK_CATEGORY'],
@@ -54,22 +83,22 @@ module CookbookRelease
54
83
  Release.new(git, opts).release!
55
84
  end
56
85
 
57
- desc "Suggest new release version"
58
- task "release:suggest_version" do
86
+ desc 'Suggest new release version'
87
+ task 'release:suggest_version' do
59
88
  git = GitUtilities.new
60
89
  release = Release.new(git)
61
90
  release.display_suggested_version(*release.new_version)
62
91
  end
63
92
 
64
- desc "Display last released version"
65
- task "release:version" do
93
+ desc 'Display last released version'
94
+ task 'release:version' do
66
95
  git = GitUtilities.new
67
96
  release = Release.new(git)
68
97
  puts release.last_release
69
98
  end
70
99
 
71
- desc "Display changelog since last release"
72
- task "release:changelog" do
100
+ desc 'Display changelog since last release'
101
+ task 'release:changelog' do
73
102
  git = GitUtilities.new
74
103
  release = Release.new(git)
75
104
  release.display_changelog(release.new_version.first)
@@ -4,9 +4,16 @@ 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
 
11
+ RISKY = 'RISKY/BREAKING (details below):'
12
+ NO_RISKY = 'NO RISKY/BREAKING COMMITS. READ FULL CHANGELOG.'
13
+ NON_NODES_ONLY = 'Non-risky/major, Non-node-only commits'
14
+ FULL = 'Full changelog:'
15
+ DETAILS = 'Details of risky commits:'
16
+
10
17
  def initialize(git, opts = {})
11
18
  @git = git
12
19
  @opts = DEFAULT_OPTS.merge(opts)
@@ -16,6 +23,18 @@ module CookbookRelease
16
23
  changelog.map(&:to_s_oneline)
17
24
  end
18
25
 
26
+ def raw_priority
27
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
28
+ result = []
29
+ if risky_commits.any?
30
+ result << "#{RISKY}\n" << risky_commits.map(&:to_s_oneline).join("\n") << "\n"
31
+ else
32
+ result << "#{NO_RISKY}\n\n"
33
+ end
34
+ result << "#{FULL}\n"
35
+ result << changelog.map(&:to_s_oneline).join("\n")
36
+ end
37
+
19
38
  def html
20
39
  result = []
21
40
  result << <<-EOH
@@ -25,6 +44,7 @@ module CookbookRelease
25
44
  result << changelog.map do |c|
26
45
  full_body ||= @opts[:expand_major] && c.major?
27
46
  full_body ||= @opts[:expand_risky] && c.risky?
47
+ full_body ||= @opts[:separate_nodes] && c.nodes_only?
28
48
  full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
29
49
  c.to_s_html(full_body)
30
50
  end.map { |c| " <p>#{c}</p>" }
@@ -35,15 +55,81 @@ module CookbookRelease
35
55
  result.join("\n")
36
56
  end
37
57
 
58
+ def html_priority
59
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
60
+ result = []
61
+ result << <<-EOH
62
+ <html>
63
+ <body>
64
+ EOH
65
+ if risky_commits.any?
66
+ result << " <p>#{RISKY}</p>\n" << risky_commits.map { |c| c.to_s_html(false) }.map {|c| " <p>#{c}</p>"}.join("\n")
67
+ else
68
+ result << " <p>#{NO_RISKY}</p>\n\n"
69
+ end
70
+ result << " <p>#{FULL}</p>\n"
71
+ result << changelog.map { |c| c.to_s_html(false) }.map { |c| " <p>#{c}</p>" }.join("\n")
72
+ if risky_commits.any?
73
+ result << "\n<p>#{DETAILS}</p>\n"
74
+ result << risky_commits.map { |c| c.to_s_html(true) }.map { |c| " <p>#{c}</p>" }.join("\n")
75
+ end
76
+ result << <<-EOH
77
+ </body>
78
+ </html>
79
+ EOH
80
+ result.join("\n")
81
+ end
82
+
38
83
  def markdown
39
84
  changelog.map do |c|
40
85
  full_body ||= @opts[:expand_major] && c.major?
41
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])
42
89
  full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit])
43
90
  c.to_s_markdown(full_body)
44
91
  end.join("\n")
45
92
  end
46
93
 
94
+ def markdown_priority
95
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
96
+ result = []
97
+ if risky_commits.any?
98
+ result << "*#{RISKY}*\n" << risky_commits.map { |c| c.to_s_markdown(false) }.join("\n") << "\n"
99
+ else
100
+ result << "*#{NO_RISKY}*\n\n"
101
+ end
102
+ result << "*#{FULL}*\n"
103
+ result << changelog.map { |c| c.to_s_markdown(false) }.join("\n")
104
+ if risky_commits.any?
105
+ result << "\n#{DETAILS}\n"
106
+ result << risky_commits.map { |c| c.to_s_markdown(true) }.join("\n")
107
+ end
108
+ result
109
+ end
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
+
47
133
  private
48
134
 
49
135
  def changelog
@@ -1,3 +1,6 @@
1
+ require 'forwardable'
2
+ require 'unicode/emoji'
3
+
1
4
  module CookbookRelease
2
5
  class Commit
3
6
  extend Forwardable
@@ -34,6 +37,10 @@ module CookbookRelease
34
37
  !!(self[:subject] =~ /\[risky\]/i)
35
38
  end
36
39
 
40
+ def nodes_only?
41
+ self[:nodes_only]
42
+ end
43
+
37
44
  def color
38
45
  case true
39
46
  when major?
@@ -59,7 +66,7 @@ module CookbookRelease
59
66
  if full && self[:body]
60
67
  result << <<-EOH
61
68
  <pre>
62
- #{self[:body]}
69
+ #{strip_change_id(self[:body])}
63
70
  </pre>
64
71
  EOH
65
72
  end
@@ -75,9 +82,24 @@ module CookbookRelease
75
82
  else
76
83
  result << "_#{self[:author]} <#{self[:email]}>_"
77
84
  end
78
- result << " `#{self[:subject]}`"
79
- result << "\n```\n#{self[:body]}\n```" if full && self[:body]
85
+ result << ' '
86
+ result << backtick_string(self[:subject])
87
+ result << "\n```\n#{strip_change_id(self[:body])}```" if full && self[:body]
80
88
  result
81
89
  end
90
+
91
+ def backtick_string(input)
92
+ s = input.gsub(/( )?(#{Unicode::Emoji::REGEX})( )?/, '` \2 `')
93
+ .gsub(/( )?``( )?/, '')
94
+ s += '`' unless s =~ /`$/
95
+ s = '`' + s unless s =~ /^`/
96
+ s
97
+ end
98
+
99
+ private
100
+
101
+ def strip_change_id(body)
102
+ body.each_line.reject {|l| l.start_with?('Change-Id') }.join
103
+ end
82
104
  end
83
105
  end
@@ -12,6 +12,7 @@ module CookbookRelease
12
12
  def initialize(options={})
13
13
  @tag_prefix = options[:tag_prefix] || ''
14
14
  cwd = options[:cwd] || Dir.pwd
15
+ @sub_dir = options[:sub_dir] # if nil takes the cwd
15
16
  @shellout_opts = {
16
17
  cwd: cwd
17
18
  }
@@ -63,7 +64,7 @@ module CookbookRelease
63
64
  end
64
65
 
65
66
  def compute_changelog(since, short_sha = true)
66
- @g.log(500).between(since, 'HEAD').map do |commit|
67
+ @g.log(500).object(@sub_dir).between(since, 'HEAD').map do |commit|
67
68
  message = commit.message.lines.map(&:chomp).compact.delete_if(&:empty?)
68
69
  Commit.new(
69
70
  author: commit.author.name,
@@ -71,7 +72,10 @@ module CookbookRelease
71
72
  subject: message.delete_at(0),
72
73
  hash: short_sha ? commit.sha[0,7] : commit.sha,
73
74
  body: message.empty? ? nil : message.join("\n"),
74
- 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?
75
79
  )
76
80
  end.reject { |commit| commit[:is_merge_commit] }
77
81
  end
@@ -86,7 +86,13 @@ module CookbookRelease
86
86
  end
87
87
 
88
88
  def release!
89
- new_version = prepare_release
89
+
90
+ new_version = begin
91
+ prepare_release
92
+ rescue ExistingRelease
93
+ raise unless ENV['COOKBOOK_RELEASE_SILENT_FAIL']
94
+ exit 0
95
+ end
90
96
  begin
91
97
  git.tag(new_version)
92
98
  display_changelog(new_version)
@@ -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
@@ -23,4 +23,16 @@ describe CookbookRelease::Commit do
23
23
  expect(minor_change) .not_to be_patch
24
24
  end
25
25
  end
26
+
27
+ describe '.to_s_markdown' do
28
+ it 'surrounds subject with backticks' do
29
+ commit = CookbookRelease::Commit.new(subject: 'This is a fix', hash: 'abcdef', author: 'Linus', email: 'linus@linux.org')
30
+ expect(commit.to_s_markdown(false)).to match(/`#{commit[:subject]}`/)
31
+ end
32
+
33
+ it 'properly handle emojis' do
34
+ commit = CookbookRelease::Commit.new(subject: 'This is a fix 🔧 and I love 🪐🚀', hash: 'abcdef', author: 'Linus', email: 'linus@linux.org')
35
+ expect(commit.to_s_markdown(false)).to match(/`This is a fix` 🔧 `and I love` 🪐🚀/)
36
+ end
37
+ end
26
38
  end
@@ -123,16 +123,35 @@ git tag 12.34.56
123
123
  cmd.run_command
124
124
  cmd.error!
125
125
  end
126
-
127
126
  changelog = git.compute_changelog('1.0.0')
128
127
  expect(changelog.size).to eq(3)
129
128
  expect(changelog.map {|c| c[:subject]}).to contain_exactly('A commit', 'Another commit', 'A third one')
130
129
  end
131
130
 
132
- it 'parse correctly commits' do
131
+ it 'shows only sub_dir commits' do
133
132
  cmds = <<-EOH
134
133
  git commit --allow-empty -m "subject" -m "body" -m "line2"
135
134
  git commit --allow-empty -m "without body"
135
+ mkdir -p subbie
136
+ echo "hello" > subbie/there
137
+ git add subbie/there
138
+ git commit -m "hello there"
139
+ EOH
140
+ sub_git = CookbookRelease::GitUtilities.new(sub_dir: 'subbie')
141
+ cmds.split("\n").each do |cmd|
142
+ cmd = Mixlib::ShellOut.new(cmd)
143
+ cmd.run_command
144
+ cmd.error!
145
+ end
146
+
147
+ changelog = sub_git.compute_changelog('1.0.0')
148
+ expect(changelog.size).to eq(1)
149
+ end
150
+
151
+ it 'parse correctly commits' do
152
+ cmds = <<-EOH
153
+ git commit --allow-empty --no-verify -m "subject" -m "body" -m "line2"
154
+ git commit --allow-empty --no-verify -m "without body"
136
155
  EOH
137
156
  cmds.split("\n").each do |cmd|
138
157
  cmd = Mixlib::ShellOut.new(cmd)
@@ -164,5 +183,32 @@ git tag 12.34.56
164
183
  changelog = git.compute_changelog('HEAD~1', false)
165
184
  expect(changelog[0][:hash].size).to eq(40)
166
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
167
213
  end
168
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.3.4
4
+ version: 1.4.5
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: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -54,6 +54,20 @@ dependencies:
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: chef
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 12.18.31
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 12.18.31
69
+ - !ruby/object:Gem::Dependency
70
+ name: git-ng
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: git-ng
84
+ name: unicode-emoji
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -181,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
195
  version: '0'
182
196
  requirements: []
183
197
  rubyforge_project:
184
- rubygems_version: 2.4.5
198
+ rubygems_version: 2.7.7
185
199
  signing_key:
186
200
  specification_version: 4
187
201
  summary: Provide primitives (and rake tasks) to release a cookbook