structured_changelog 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b739ec968c42936d856aa3788cf0429a1381f1a4
4
- data.tar.gz: 7723700057200b69557b1a8fcfbf6842b3b4d60f
3
+ metadata.gz: be75d779c18c4c812b6d42568422f7204fbcf7c2
4
+ data.tar.gz: 109cb7700121b7ca516b81dbbfcd93b8f4efcf7c
5
5
  SHA512:
6
- metadata.gz: f21e553a2ef385497c4319ac5e5f640c5cadb3e4287e8e21de82e1f71cea7d770ca9afecfc5ed28da237adb0bf79d612f1ae38e1a69fd5f3b3fe24227c385778
7
- data.tar.gz: 9c53f76476323d2f51c6fea3eb2562d9109cdf802ebfdb79536b3006dc36e6f4552f4922ba0dbb4c277742d7b2b7533e1fce0b7a97a2325a467fbbf738c1f6b7
6
+ metadata.gz: eb30d9b5f2bf621ba062a8aa1d70b8eb3f9224bccadf13ac7e08a3a36856c551761f35affec2c653f4b6f16c4b1d5af75fb16cf126ba77be5d14b4e0918178c0
7
+ data.tar.gz: a18d973aefddb4c97b5dbfb3d7e92b4d5396c59aba1dd8b3fc9694c5dd95da3e94f0cfc0a7d93595f25827e5268683a3786fbbcc3fc018e91e21286929edcb3d
@@ -5,6 +5,11 @@
5
5
  * require release block lines to be ordered in descending severity
6
6
  * disable strict semver version validation before 1.0.0
7
7
 
8
+ ## RELEASE 0.11.0
9
+
10
+ * FEATURE: `changelog:preview` task will output a preview of the release section that `changelog:compile` would add to the changelog
11
+ * ENHANCEMENT: the `changelog:compile` task now shows up in rake -T listings
12
+
8
13
  ## RELEASE 0.10.2
9
14
 
10
15
  * ENHANCEMENT: release lines can now be embedded in any commit message body
data/README.md CHANGED
@@ -65,7 +65,7 @@ as usual to actually release your gem.
65
65
 
66
66
  ## Viewing Release Notes
67
67
 
68
- To view the release notes of the current release:`
68
+ To view the release notes of the current release:
69
69
 
70
70
  $ rake changelog:notes
71
71
  $ rake changelog:notes[current]
@@ -0,0 +1,50 @@
1
+ require 'structured_changelog/core_ext/string'
2
+ require 'structured_changelog/core_ext/gem'
3
+
4
+ class StructuredChangelog
5
+ class ReleasePreview
6
+ def initialize(changelog:, repo:)
7
+ @changelog = changelog
8
+ @repo = repo
9
+ end
10
+
11
+ def to_s
12
+ "## RELEASE #{new_version}\n\n#{release_notes}"
13
+ end
14
+
15
+ def empty?
16
+ release_notes.empty?
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :changelog, :repo
22
+
23
+ def release_notes
24
+ @release_notes ||= repo.log.between("v#{current_version}").
25
+ map(&:message).
26
+ flat_map { |message| message.split("\n") }.
27
+ grep(/^\*\ (BREAKING|FEATURE|ENHANCEMENT|FIX|DEPRECATION)\:/).
28
+ map(&:strip).
29
+ join("\n")
30
+ end
31
+
32
+ def current_version
33
+ @current_version ||= changelog.version
34
+ end
35
+
36
+ def new_version
37
+ @new_version ||= if release_notes.match?(/^*\ BREAKING:/)
38
+ current_version.bump_major
39
+ elsif release_notes.match?(/^*\ FEATURE:/)
40
+ current_version.bump_minor
41
+ elsif release_notes.match?(/^*\ FIX:/)
42
+ current_version.bump_patch
43
+ elsif release_notes.match?(/^*\ ENHANCEMENT:/)
44
+ current_version.bump_patch
45
+ elsif release_notes.match?(/^*\ DEPRECATION:/)
46
+ current_version.bump_patch
47
+ end
48
+ end
49
+ end
50
+ end
@@ -31,7 +31,7 @@ class StructuredChangelog
31
31
  end
32
32
  end
33
33
 
34
- Gem::Version.new(nil)
34
+ Gem::Version.new("")
35
35
  end
36
36
 
37
37
  private
@@ -1,41 +1,26 @@
1
- require 'structured_changelog'
2
- require 'structured_changelog/core_ext/string'
3
- require 'structured_changelog/core_ext/gem'
4
1
  require 'git'
5
2
 
3
+ require 'structured_changelog'
4
+ require 'structured_changelog/release_preview'
5
+
6
+ desc "Pull all release lines from git commits since the last release and insert them into a release section in the changelog"
6
7
  task "changelog:compile", [:repo_path, :changelog_path] do |_task, arguments|
7
8
  repo_path = arguments.to_h.fetch(:repo_path) { Pathname.pwd }
8
9
  changelog_path = arguments.to_h.fetch(:changelog_path) { Pathname.pwd/"CHANGELOG.md" }
9
10
 
10
- current_version = StructuredChangelog.new(changelog_path).version
11
+ changelog = StructuredChangelog.new(changelog_path)
11
12
 
12
- repo = Git.open(repo_path)
13
-
14
- release_notes = repo.log.between("v#{current_version}").
15
- map(&:message).
16
- flat_map { |message| message.split("\n") }.
17
- grep(/^\*\ (BREAKING|FEATURE|ENHANCEMENT|FIX|DEPRECATION)\:/).
18
- map(&:strip).
19
- join("\n")
20
-
21
- abort("No release notes since the last release") if release_notes.empty?
13
+ release_preview = StructuredChangelog::ReleasePreview.new(
14
+ changelog: changelog,
15
+ repo: Git.open(repo_path),
16
+ )
22
17
 
23
- new_version = if release_notes.match?(/^*\ BREAKING:/)
24
- current_version.bump_major
25
- elsif release_notes.match?(/^*\ FEATURE:/)
26
- current_version.bump_minor
27
- elsif release_notes.match?(/^*\ FIX:/)
28
- current_version.bump_patch
29
- elsif release_notes.match?(/^*\ ENHANCEMENT:/)
30
- current_version.bump_patch
31
- elsif release_notes.match?(/^*\ DEPRECATION:/)
32
- current_version.bump_patch
33
- end
18
+ abort("No release notes since the last release") if release_preview.empty?
34
19
 
35
20
  changelog_path.write(
36
21
  changelog_path.read.sub(
37
- /^##\ RELEASE\ #{current_version}/,
38
- "## RELEASE #{new_version}\n\n#{release_notes}\n\n## RELEASE #{current_version}"
22
+ /^##\ RELEASE\ #{changelog.version}/,
23
+ "#{release_preview}\n\n## RELEASE #{changelog.version}"
39
24
  )
40
25
  )
41
26
  end
@@ -0,0 +1,21 @@
1
+ require 'git'
2
+
3
+ require 'structured_changelog'
4
+ require 'structured_changelog/release_preview'
5
+
6
+ desc "View the release section changelog:compile would insert into the changelog without actually doing so"
7
+ task 'changelog:preview', [:repo_path, :changelog_path] do |_task, arguments|
8
+ repo_path = arguments.to_h.fetch(:repo_path) { Pathname.pwd }
9
+ changelog_path = arguments.to_h.fetch(:changelog_path) { Pathname.pwd/"CHANGELOG.md" }
10
+
11
+ changelog = StructuredChangelog.new(changelog_path)
12
+
13
+ release_preview = StructuredChangelog::ReleasePreview.new(
14
+ changelog: changelog,
15
+ repo: Git.open(repo_path),
16
+ )
17
+
18
+ abort("No release notes since the last release") if release_preview.empty?
19
+
20
+ puts release_preview.to_s
21
+ end
@@ -1,3 +1,3 @@
1
1
  class StructuredChangelog
2
- VERSION = "0.10.2"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structured_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hoffman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,12 +137,14 @@ files:
137
137
  - lib/structured_changelog/release_filters/matches_versions_between.rb
138
138
  - lib/structured_changelog/release_filters/matches_versions_greater_than_or_equal_to.rb
139
139
  - lib/structured_changelog/release_filters/matches_versions_less_than_or_equal_to.rb
140
+ - lib/structured_changelog/release_preview.rb
140
141
  - lib/structured_changelog/roadmap.rb
141
142
  - lib/structured_changelog/tasks.rb
142
143
  - lib/structured_changelog/tasks/commit.rb
143
144
  - lib/structured_changelog/tasks/compile.rb
144
145
  - lib/structured_changelog/tasks/notes.rb
145
146
  - lib/structured_changelog/tasks/prep.rb
147
+ - lib/structured_changelog/tasks/preview.rb
146
148
  - lib/structured_changelog/tasks/recent.rb
147
149
  - lib/structured_changelog/tasks/release.rb
148
150
  - lib/structured_changelog/tasks/sync.rb
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  version: '0'
171
173
  requirements: []
172
174
  rubyforge_project:
173
- rubygems_version: 2.6.12
175
+ rubygems_version: 2.6.3
174
176
  signing_key:
175
177
  specification_version: 4
176
178
  summary: A useful changelog, for a change.