cookbook-release 1.3.4 → 1.4.0

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: 57e2bcc2990d45377c96a8b34b77103cff548f5ca7eaed951e946f0d9303cfa3
4
+ data.tar.gz: 89ddf7b79d5999cfd47d2ad6350d80801e3b6de8b2d048a8ee78516c8945585b
5
5
  SHA512:
6
- metadata.gz: 4fa616dc27a0e09e72c1ce1a4c85dc9462ccfedaa771e36267ef3013434da2b8b347ecce296af6c6d340e7ff5eefcb46da9f5e784ec9c469b57ea85aeb825b80
7
- data.tar.gz: 95fdeae091d01fb3db067cf525cc7beb3cc1c55c2cf0517b360b2e719549dd0be950f703ba063f550e911db795693129ed4ac8f263cff0c8df0e228533a30dd7
6
+ metadata.gz: 059852351bb66fd6369180260c30e59764252cd78847c40190eaca36e97375dea5fbb97e332a7518f8d57c24e7d31f41ec410a7a6d7b79ee01741dc0080f9cf2
7
+ data.tar.gz: c9060e027e88bce6a27fdf280fb3684360e64e94ddd4d6b7292f5e2b3e34cc40b1952242944f5d069db9493cb1888d5343bd8520d91208069db5935451cd341e
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
3
+ - 2.4.0
4
+ before_install:
5
+ - rvm @global do gem uninstall bundler -a -x
6
+ - rvm @global do gem install bundler -v 1.15.4
4
7
  deploy:
5
8
  provider: rubygems
6
9
  api_key:
@@ -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.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'
@@ -12,14 +12,20 @@ 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
15
+ desc 'Display raw changelog between branches'
16
+ task 'changelog:raw' do
17
17
  git = GitUtilities.new
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
21
+ desc 'Display raw changelog between branches with risky commits on top'
22
+ task 'changelog:raw_priority' do
23
+ git = GitUtilities.new
24
+ puts Changelog.new(git, opts).raw_priority
25
+ end
26
+
27
+ desc 'Display html changelog between branches'
28
+ task 'changelog:html' do
23
29
  git = GitUtilities.new
24
30
  html = Changelog.new(git, opts).html
25
31
  if block_given?
@@ -28,11 +34,27 @@ module CookbookRelease
28
34
  puts html
29
35
  end
30
36
 
37
+ desc 'Display html changelog between branches with risky commits on top'
38
+ task 'changelog:html_priority' do
39
+ git = GitUtilities.new
40
+ html = Changelog.new(git, opts).html_priority
41
+ if block_given?
42
+ html = html_block.call(html)
43
+ end
44
+ puts html
45
+ end
46
+
31
47
  desc 'Display markdown changelog between branches'
32
48
  task 'changelog:markdown' do
33
49
  git = GitUtilities.new
34
50
  puts Changelog.new(git, opts).markdown
35
51
  end
52
+
53
+ desc 'Display markdown changelog between branches with risky commits on top'
54
+ task 'changelog:markdown_priority' do
55
+ git = GitUtilities.new
56
+ puts Changelog.new(git, opts).markdown_priority
57
+ end
36
58
  end
37
59
  end
38
60
 
@@ -44,8 +66,8 @@ module CookbookRelease
44
66
 
45
67
  def define_tasks(namespaced)
46
68
 
47
- desc "Prepare cookbook release and push tag to git"
48
- task "release!" do
69
+ desc 'Prepare cookbook release and push tag to git'
70
+ task 'release!' do
49
71
  opts = {
50
72
  no_prompt: ENV['NO_PROMPT'],
51
73
  category: ENV['COOKBOOK_CATEGORY'],
@@ -54,22 +76,22 @@ module CookbookRelease
54
76
  Release.new(git, opts).release!
55
77
  end
56
78
 
57
- desc "Suggest new release version"
58
- task "release:suggest_version" do
79
+ desc 'Suggest new release version'
80
+ task 'release:suggest_version' do
59
81
  git = GitUtilities.new
60
82
  release = Release.new(git)
61
83
  release.display_suggested_version(*release.new_version)
62
84
  end
63
85
 
64
- desc "Display last released version"
65
- task "release:version" do
86
+ desc 'Display last released version'
87
+ task 'release:version' do
66
88
  git = GitUtilities.new
67
89
  release = Release.new(git)
68
90
  puts release.last_release
69
91
  end
70
92
 
71
- desc "Display changelog since last release"
72
- task "release:changelog" do
93
+ desc 'Display changelog since last release'
94
+ task 'release:changelog' do
73
95
  git = GitUtilities.new
74
96
  release = Release.new(git)
75
97
  release.display_changelog(release.new_version.first)
@@ -7,6 +7,11 @@ module CookbookRelease
7
7
  short_sha: true
8
8
  }
9
9
 
10
+ RISKY = 'RISKY/BREAKING (details below):'
11
+ NO_RISKY = 'NO RISKY/BREAKING COMMITS. READ FULL CHANGELOG.'
12
+ FULL = 'Full changelog:'
13
+ DETAILS = 'Details of risky commits:'
14
+
10
15
  def initialize(git, opts = {})
11
16
  @git = git
12
17
  @opts = DEFAULT_OPTS.merge(opts)
@@ -16,6 +21,18 @@ module CookbookRelease
16
21
  changelog.map(&:to_s_oneline)
17
22
  end
18
23
 
24
+ def raw_priority
25
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
26
+ result = []
27
+ if risky_commits.any?
28
+ result << "#{RISKY}\n" << risky_commits.map(&:to_s_oneline).join("\n") << "\n"
29
+ else
30
+ result << "#{NO_RISKY}\n\n"
31
+ end
32
+ result << "#{FULL}\n"
33
+ result << changelog.map(&:to_s_oneline).join("\n")
34
+ end
35
+
19
36
  def html
20
37
  result = []
21
38
  result << <<-EOH
@@ -35,6 +52,31 @@ module CookbookRelease
35
52
  result.join("\n")
36
53
  end
37
54
 
55
+ def html_priority
56
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
57
+ result = []
58
+ result << <<-EOH
59
+ <html>
60
+ <body>
61
+ EOH
62
+ if risky_commits.any?
63
+ result << " <p>#{RISKY}</p>\n" << risky_commits.map { |c| c.to_s_html(false) }.map {|c| " <p>#{c}</p>"}.join("\n")
64
+ else
65
+ result << " <p>#{NO_RISKY}</p>\n\n"
66
+ end
67
+ result << " <p>#{FULL}</p>\n"
68
+ result << changelog.map { |c| c.to_s_html(false) }.map { |c| " <p>#{c}</p>" }.join("\n")
69
+ if risky_commits.any?
70
+ result << "\n<p>#{DETAILS}</p>\n"
71
+ result << risky_commits.map { |c| c.to_s_html(true) }.map { |c| " <p>#{c}</p>" }.join("\n")
72
+ end
73
+ result << <<-EOH
74
+ </body>
75
+ </html>
76
+ EOH
77
+ result.join("\n")
78
+ end
79
+
38
80
  def markdown
39
81
  changelog.map do |c|
40
82
  full_body ||= @opts[:expand_major] && c.major?
@@ -44,6 +86,23 @@ module CookbookRelease
44
86
  end.join("\n")
45
87
  end
46
88
 
89
+ def markdown_priority
90
+ risky_commits = changelog.select { |c| c.risky? || c.major? }
91
+ result = []
92
+ if risky_commits.any?
93
+ result << "*#{RISKY}*\n" << risky_commits.map { |c| c.to_s_markdown(false) }.join("\n") << "\n"
94
+ else
95
+ result << "*#{NO_RISKY}*\n\n"
96
+ end
97
+ result << "*#{FULL}*\n"
98
+ result << changelog.map { |c| c.to_s_markdown(false) }.join("\n")
99
+ if risky_commits.any?
100
+ result << "\n#{DETAILS}\n"
101
+ result << risky_commits.map { |c| c.to_s_markdown(true) }.join("\n")
102
+ end
103
+ result
104
+ end
105
+
47
106
  private
48
107
 
49
108
  def changelog
@@ -59,7 +59,7 @@ module CookbookRelease
59
59
  if full && self[:body]
60
60
  result << <<-EOH
61
61
  <pre>
62
- #{self[:body]}
62
+ #{strip_change_id(self[:body])}
63
63
  </pre>
64
64
  EOH
65
65
  end
@@ -76,8 +76,14 @@ module CookbookRelease
76
76
  result << "_#{self[:author]} <#{self[:email]}>_"
77
77
  end
78
78
  result << " `#{self[:subject]}`"
79
- result << "\n```\n#{self[:body]}\n```" if full && self[:body]
79
+ result << "\n```\n#{strip_change_id(self[:body])}```" if full && self[:body]
80
80
  result
81
81
  end
82
+
83
+ private
84
+
85
+ def strip_change_id(body)
86
+ body.each_line.reject {|l| l.start_with?('Change-Id') }.join
87
+ end
82
88
  end
83
89
  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)
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.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: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-11-02 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.4.5
184
+ rubygems_version: 2.7.0
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Provide primitives (and rake tasks) to release a cookbook