kettle-changelog 1.0.16 → 1.0.18

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
2
  SHA256:
3
- metadata.gz: e6072cef22f9c1a91d39f3b7b03279f0abe772c4777944e220a84b4f7e961432
4
- data.tar.gz: 747cbf50f0af54da01b65e619dd3dc629e3f4f7d05dc0ec8fc7655214965ce61
3
+ metadata.gz: 0c957b8e471874ff01f46eef2e4158cae23011bef9ae121a926e76f938dfbd2d
4
+ data.tar.gz: 90891a26ddefcda56b683f1b6c5944c25b12933f6df934485c75d866d537b7dd
5
5
  SHA512:
6
- metadata.gz: 6e86be3891856e5c3a4cff045df5cf149e3527a360baa483d96617e3786a0a570e86cc2674f60882a37a191e6fd2528b2a77fd1b9a0cb9ec015d017af4051819
7
- data.tar.gz: f735f88af50d17d5ddd519ea1d5768103bce821454ace82d29eec83a3f1943aa09562b896aaa2d6f68cab4b9df55f475dfbe97c9eb00e9d856b9c72e5487a8f4
6
+ metadata.gz: 44952c43def1291899fb270724ea6e90e96a116c22cbdd2f675efa69c95ac184323761bf217b46af175c31baa39dfe5c27bc6e19ac20ce13fb4b086ce348deb6
7
+ data.tar.gz: 5c0c1941b9dede699f0081c496ab840d545decd896cea623ae22b9f3ebce9d0e56ec4fc8fbc0bd940bf3a25250f5ecc9f7f09dd5e82024ceea82e3e0278f6ffd
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,38 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [1.0.18] - 2026-11-08
34
+
35
+ - TAG: [v1.0.18][1.0.18t]
36
+ - COVERAGE: 93.62% -- 1263/1349 lines in 8 files
37
+ - BRANCH COVERAGE: 78.31% -- 462/590 branches in 8 files
38
+ - 36.73% documented
39
+
40
+ ### Fixed
41
+
42
+ - Support slash-separated release dates (e.g. `## 3.14.0 / 2026-07-26`) during release extraction.
43
+
44
+ ## [1.0.17] - 2026-11-08
45
+
46
+ - TAG: [v1.0.17][1.0.17t]
47
+ - COVERAGE: 93.62% -- 1263/1349 lines in 8 files
48
+ - BRANCH COVERAGE: 78.31% -- 462/590 branches in 8 files
49
+ - 36.73% documented
50
+
51
+ ### Added
52
+
53
+ - Extract a selected changelog release as structured JSON with `--release` or `--latest`, including matching major and minor version ranges.
54
+
55
+ ### Changed
56
+
57
+ - [kc] kettle-jem/prepare: updated 11 project files:
58
+ - dependencies (11)
59
+
60
+ - [kc] kettle-jem/template: updated 5 project files:
61
+ - dependencies (3)
62
+ - other (1)
63
+ - workflows (1)
64
+
33
65
  ## [1.0.16] - 2026-11-03
34
66
 
35
67
  - TAG: [v1.0.16][1.0.16t]
@@ -368,7 +400,11 @@ Please file a bug if you notice a violation of semantic versioning.
368
400
 
369
401
  - Initial release
370
402
 
371
- [Unreleased]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.16...HEAD
403
+ [Unreleased]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.18...HEAD
404
+ [1.0.18]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.17...v1.0.18
405
+ [1.0.18t]: https://github.com/kettle-dev/kettle-changelog/releases/tag/v1.0.18
406
+ [1.0.17]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.16...v1.0.17
407
+ [1.0.17t]: https://github.com/kettle-dev/kettle-changelog/releases/tag/v1.0.17
372
408
  [1.0.16]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.15...v1.0.16
373
409
  [1.0.16t]: https://github.com/kettle-dev/kettle-changelog/releases/tag/v1.0.16
374
410
  [1.0.15]: https://github.com/kettle-dev/kettle-changelog/compare/v1.0.14...v1.0.15
data/README.md CHANGED
@@ -132,6 +132,20 @@ Use `--yes` for non-interactive release automation. Add a note without preparing
132
132
  bundle exec kettle-changelog --add-unreleased-entry --section Fixed --entry "Describe the fix."
133
133
  ```
134
134
 
135
+ Extract a specific release without modifying the changelog:
136
+
137
+ ```sh
138
+ bundle exec kettle-changelog --release v1.2.3 --file CHANGELOG.md
139
+ # Or pipe Markdown to stdin:
140
+ cat CHANGELOG.md | bundle exec kettle-changelog --release 1.2.3
141
+ # Select every release in a major or minor version:
142
+ bundle exec kettle-changelog --release v3.2 --file CHANGELOG.md
143
+ # Select the first published release instead:
144
+ bundle exec kettle-changelog --latest --file CHANGELOG.md
145
+ ```
146
+
147
+ `--latest` and `--release` are mutually exclusive. A one- or two-segment version (such as `3` or `v3.2`) returns an array of matching releases in changelog order; full versions and `--latest` return one object. Both forms accept an optional `v` prefix. No matches exit nonzero. The command prints JSON with `version`, `date`, `tag`, `markdown`, `coverage`, `branch_coverage`, and `documented`. Missing metadata is `null`. The Markdown body excludes the release heading and contains its referenced link definitions, found anywhere in the changelog. Shared definitions are included independently in each matching release. Release headings must be level two and contain a three-part version, optionally prefixed with `v` and followed by a date and tag link. A subsequent level-two heading or a level-three community, sponsorship, funding, contributing, acknowledgments, or license heading ends the release. Missing or ambiguous releases and invalid input exit nonzero. The Ruby API is `Kettle::Changelog::Release.extract(content: markdown, version: "1.2.3")` and raises `Kettle::Changelog::Error` on failure.
148
+
135
149
  Useful queries and maintenance commands include `--pending-release`, `--release-state`, `--release-stats`, `--reformat`, `--update-prep`, `--json`, and `--events=changelog`. Run `bundle exec kettle-changelog --help` for the complete option list.
136
150
 
137
151
  ## 🔐 Security
@@ -383,7 +397,7 @@ Thanks for RTFM. ☺️
383
397
  [📌gitmoji]: https://gitmoji.dev
384
398
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
385
399
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
386
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-1.265-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
400
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-1.349-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
387
401
  [🔐security]: https://github.com/kettle-dev/kettle-changelog/blob/main/SECURITY.md
388
402
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
389
403
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
data/exe/kettle-changelog CHANGED
@@ -53,7 +53,7 @@ begin
53
53
  require "kettle/ndjson"
54
54
  require "kettle/dev/executable_version"
55
55
  Kettle::Dev::ExecutableVersion.print_and_exit!(script_basename, ARGV, value_option: true)
56
- machine_output = ARGV.any? { |arg| arg == "--json" || arg.start_with?("--events") }
56
+ machine_output = ARGV.any? { |arg| arg == "--json" || arg == "--latest" || arg == "--release" || arg.start_with?("--release=") || arg.start_with?("--events") }
57
57
  Kettle::Dev::ExecutableVersion.print_header(script_basename) unless machine_output
58
58
  rescue LoadError => e
59
59
  warn("#{script_basename}: could not load dependency: #{e.class}: #{e.message}")
@@ -82,6 +82,8 @@ if ARGV.include?("-h") || ARGV.include?("--help")
82
82
  --pending-release Query whether the changelog has release work pending; exits 0 for yes, 1 for no
83
83
  --release-state,
84
84
  --release-status Print changelog release state, including latest published release and pending sources
85
+ --release VERSION Extract matching release(s) as JSON (full, major, or major.minor; --file or stdin)
86
+ --latest Extract the latest release as JSON (read-only; --file PATH or stdin)
85
87
  --release-stats Print the latest released section's coverage/doc stats from a changelog (read-only;
86
88
  --file PATH or stdin; add --json; exits 1 when line coverage is not recorded)
87
89
  --refresh-cache Bypass cached gem.coop version data for this invocation
@@ -211,9 +213,18 @@ begin
211
213
 
212
214
  historical_backfill_version = extract_option_arg!(ARGV, "--backfill-released-version")
213
215
  coverage_gemfile = extract_option_arg!(ARGV, "--coverage-gemfile")
216
+ release_version = extract_option_arg!(ARGV, "--release")
217
+ latest_release = ARGV.delete("--latest")
214
218
  release_stats_query = ARGV.delete("--release-stats")
215
219
  release_stats_file = extract_option_arg!(ARGV, "--file")
216
220
 
221
+ if release_version || latest_release
222
+ raise Kettle::Changelog::Error, "--release cannot be combined with other options" unless ARGV.empty? && !release_stats_query && !version_override && !events_output
223
+ text = (release_stats_file.nil? || release_stats_file == "-") ? $stdin.read : File.read(release_stats_file)
224
+ puts JSON.pretty_generate(Kettle::Changelog::Release.extract(content: text, version: release_version, latest: !!latest_release))
225
+ exit 0
226
+ end
227
+
217
228
  if release_stats_query
218
229
  # Read-only: no project root, git, network or version detection. Reads --file PATH, or stdin when absent/"-".
219
230
  text = (release_stats_file.nil? || release_stats_file == "-") ? $stdin.read : File.read(release_stats_file)
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kettle
4
+ module Changelog
5
+ # Extracts releases without changing the input document.
6
+ module Release
7
+ HEADING = /\A(?:\[)?(v?\d+\.\d+\.\d+[0-9A-Za-z.+-]*)(?:\])?(?:\s+(?:[-\/]\s+)?(\d{4}-\d{2}-\d{2}))?(?:\s+\([^\n]*\))?\s*\z/
8
+ DEFINITION = /\A {0,3}\[([^\]]+)\]:[ \t]*(.*)$/
9
+ FOOTER = /\A(?:community|sponsors?|sponsorship|support(?:ers| us)?|funding|contributing|contributors|acknowledg(?:e)?ments|license)\b/i
10
+
11
+ module_function
12
+
13
+ # @param content [String] Markdown changelog
14
+ # @param version [String] release version or tag (with or without v)
15
+ # @return [Hash, Array<Hash>] a release, or matching releases for a partial version
16
+ # @raise [Kettle::Changelog::Error] when extraction is ambiguous or fails
17
+ def extract(content:, version: nil, latest: false, **options)
18
+ raise Error, "changelog must be a valid nonempty UTF-8 string" unless content.is_a?(String) && content.valid_encoding? && !content.strip.empty?
19
+ raise Error, "specify a version or latest" unless latest != !version.nil?
20
+ valid_version = version.is_a?(String) && version.match?(/\Av?(?:\d+|\d+\.\d+|\d+\.\d+\.\d+[0-9A-Za-z.+-]*)\z/)
21
+ raise Error, "version must be a release version or tag" if !latest && !valid_version
22
+
23
+ require "ast/crispr/markdown/markly"
24
+ context = Ast::Crispr::Markdown::Markly.document_context(content: content, source_label: "changelog")
25
+ headings = context.structural_owners(owner_scope: :heading_sections).sort_by { |owner| owner.location.start_line }
26
+ partial = !latest && version.match?(/\Av?\d+(?:\.\d+)?\z/)
27
+ requested = version&.delete_prefix("v")
28
+ matches = headings.select do |heading|
29
+ match = heading.heading_text.to_s.strip.match(HEADING)
30
+ release_version = match && match[1].delete_prefix("v")
31
+ heading.level == 2 && match && (latest || (partial ? release_version.start_with?("#{requested}.") : release_version == requested))
32
+ end
33
+ matches = matches.first(1) if latest
34
+ raise Error, "no release found for #{latest ? "latest" : version.inspect}" if matches.empty?
35
+ versions = matches.map { |heading| heading.heading_text.to_s.strip.match(HEADING)[1].delete_prefix("v") }
36
+ raise Error, "ambiguous release for #{version.inspect}" if versions.uniq.length != versions.length || (!partial && matches.length != 1)
37
+
38
+ releases = matches.map { |selected| extract_heading(content, headings, selected) }
39
+ partial ? releases : releases.first
40
+ rescue LoadError => e
41
+ raise Error, "release extraction requires the Markdown parser: #{e.message}"
42
+ end
43
+
44
+ def extract_heading(content, headings, selected)
45
+ heading_match = selected.heading_text.to_s.strip.match(HEADING)
46
+ start = selected.location.start_line
47
+ boundary = headings.find do |heading|
48
+ heading.location.start_line > start && (heading.level <= 2 || (heading.level == 3 && heading.heading_text.to_s.strip.match?(FOOTER)))
49
+ end
50
+ lines = content.lines
51
+ finish = boundary ? boundary.location.start_line - 1 : lines.length
52
+ body_lines = lines[start...finish].to_a
53
+ # Reference definitions are document scoped; remove them from the body and append only those used.
54
+ definitions = {}
55
+ definition_lines = []
56
+ fence = nil
57
+ lines.each_with_index do |line, index|
58
+ marker = line[/\A {0,3}(`{3,}|~{3,})/, 1]
59
+ if marker
60
+ if fence.nil?
61
+ fence = marker
62
+ elsif marker[0] == fence[0] && marker.length >= fence.length
63
+ fence = nil
64
+ end
65
+ next
66
+ end
67
+ next if fence
68
+
69
+ match = line.match(DEFINITION)
70
+ next unless match
71
+
72
+ definition = line.dup
73
+ indices = [index]
74
+ continuation = index + 1
75
+ if match[2].strip.empty?
76
+ destination = lines[continuation]
77
+ next unless destination&.match?(/\A {1,3}\S/)
78
+
79
+ definition << destination
80
+ indices << continuation
81
+ continuation += 1
82
+ end
83
+ title = lines[continuation]
84
+ if title&.match?(/\A {1,3}(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\))[ \t]*\r?\n?\z/)
85
+ definition << title
86
+ indices << continuation
87
+ end
88
+ definitions[normalize_label(match[1])] ||= definition
89
+ definition_lines.concat(indices)
90
+ end
91
+ body_lines = body_lines.each_with_index.reject { |_line, index| definition_lines.include?(start + index) }.map(&:first)
92
+ body = body_lines.join.strip
93
+ used = definitions.select do |label, _line|
94
+ body.scan(/\[([^\]]+)\](?:\[([^\]]*)\])?/).any? do |first, second|
95
+ normalize_label((second.nil? || second.empty?) ? first : second) == label
96
+ end
97
+ end
98
+ body = ([body] + used.values.map(&:strip)).reject(&:empty?).join("\n\n")
99
+ stats_heading = "## [#{heading_match[1].delete_prefix("v")}]"
100
+ stats_heading += " - #{heading_match[2]}" if heading_match[2]
101
+ stats = ReleaseStats.parse("#{stats_heading}\n#{body}")
102
+ tag = body[/^\s*-\s+TAG:\s*\[([^\]]+)\]/, 1]
103
+ heading_tag_ref = selected.heading_source.to_s[/\[tag\]\[([^\]]+)\]/i, 1]
104
+ if !tag && heading_tag_ref
105
+ tag = definitions[normalize_label(heading_tag_ref)].to_s[%r{/releases/tag/([^\s>]+)}, 1]
106
+ end
107
+ {version: heading_match[1].delete_prefix("v"), date: heading_match[2], tag: tag, markdown: body.empty? ? "" : "#{body}\n", coverage: stats[:coverage], branch_coverage: stats[:branch_coverage], documented: stats[:documented]}
108
+ end
109
+ private_class_method :extract_heading
110
+
111
+ def normalize_label(label)
112
+ label.to_s.strip.gsub(/\s+/, " ").downcase
113
+ end
114
+ private_class_method :normalize_label
115
+ end
116
+ end
117
+ end
@@ -5,7 +5,7 @@ module Kettle
5
5
  # Version namespace for this gem.
6
6
  module Version
7
7
  # Current gem version.
8
- VERSION = "1.0.16"
8
+ VERSION = "1.0.18"
9
9
  end
10
10
  # Current gem version exposed at the traditional constant location.
11
11
  VERSION = Version::VERSION # Traditional Constant Location
@@ -10,6 +10,7 @@ module Kettle
10
10
 
11
11
  autoload :CLI, "kettle/changelog/cli"
12
12
  autoload :EntryAdder, "kettle/changelog/entry_adder"
13
+ autoload :Release, "kettle/changelog/release"
13
14
  autoload :ReleaseStats, "kettle/changelog/release_stats"
14
15
  autoload :KeyedEntryUpserter, "kettle/changelog/keyed_entry_upserter"
15
16
  autoload :TransferMerger, "kettle/changelog/transfer_merger"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kettle-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '3.1'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 3.1.26
69
+ version: 3.1.28
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '3.1'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 3.1.26
79
+ version: 3.1.28
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: version_gem
82
82
  requirement: !ruby/object:Gem::Requirement
@@ -296,6 +296,7 @@ files:
296
296
  - lib/kettle/changelog/cli.rb
297
297
  - lib/kettle/changelog/entry_adder.rb
298
298
  - lib/kettle/changelog/keyed_entry_upserter.rb
299
+ - lib/kettle/changelog/release.rb
299
300
  - lib/kettle/changelog/release_stats.rb
300
301
  - lib/kettle/changelog/transfer_merger.rb
301
302
  - lib/kettle/changelog/version.rb
@@ -305,10 +306,10 @@ licenses:
305
306
  - AGPL-3.0-only
306
307
  metadata:
307
308
  homepage_uri: https://kettle-changelog.galtzo.com
308
- source_code_uri: https://github.com/kettle-dev/kettle-changelog/tree/v1.0.16
309
- changelog_uri: https://github.com/kettle-dev/kettle-changelog/blob/v1.0.16/CHANGELOG.md
309
+ source_code_uri: https://github.com/kettle-dev/kettle-changelog/tree/v1.0.18
310
+ changelog_uri: https://github.com/kettle-dev/kettle-changelog/blob/v1.0.18/CHANGELOG.md
310
311
  bug_tracker_uri: https://github.com/kettle-dev/kettle-changelog/issues
311
- documentation_uri: https://www.rubydoc.info/gems/kettle-changelog/1.0.16
312
+ documentation_uri: https://www.rubydoc.info/gems/kettle-changelog/1.0.18
312
313
  funding_uri: https://github.com/sponsors/pboling
313
314
  wiki_uri: https://github.com/kettle-dev/kettle-changelog/wiki
314
315
  news_uri: https://www.railsbling.com/tags/kettle-changelog
@@ -338,7 +339,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
339
  - !ruby/object:Gem::Version
339
340
  version: '0'
340
341
  requirements: []
341
- rubygems_version: 4.0.20
342
+ rubygems_version: 4.0.24
342
343
  specification_version: 4
343
344
  summary: "\U0001F4DD Release and maintain structured CHANGELOG.md files."
344
345
  test_files: []
metadata.gz.sig CHANGED
@@ -1 +1,3 @@
1
- !RY�� ϩ?G�� cu�]�3�.��]�D+l�D�w�Vr;��z ��ٌ��sK�x~�Č�4%ێ�����)���'�A72x3�U�Ԋ���vK:�+ �G�_$=�G����*4�Fc���$����C1E���2�ϕHr:d���6ȯ�F%�#G"!n���C�C���<:C�[b��@"�nR �1@̘�<�"a R<��I���F5�Mk��k�c��!�� �T��y��ә� $?�(_[���{ѽZ�5P� nq�d�;�G����z��σ:5�}�xS��B۵v�g�������_i1G���$FH����t�<^�S�2����m��.�8;lPi��`@f�`8�߫/�����d��׆j�
1
+ 7f�O��O�Q�����0ch�� !8��d�{���/˭��<�����^?Y$n��U*$m ��0.��ξk�H�d�זu�FSՖ gir��ʶ% 5)~��?]�b"�#��{�O$혷�5�
2
+ ��VV6o��l�s��/����ـ���'�:���3���9c�UG��<���U�{��k]љ���4��L��e�P䨶|�J���PCfa�'�s}��
3
+ 0����|�K�rt���gw$-�� ���6O��3�j'�: ��e1�ۓ�6�))�^���|s�U�T