easy_changelog 0.3.2 → 1.0.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
2
  SHA256:
3
- metadata.gz: 67a8b74013e659178c9d4eeab9218d505a786eb6f4255625222afa97e7a82814
4
- data.tar.gz: 24c7bf302f69a192927817c87011fc9c3a39208f1d20f89376fac8f2c4c3cb5a
3
+ metadata.gz: e400f241e2089e8ee8b3141460ee11584b671f8d418e7580c8c61ac435725b53
4
+ data.tar.gz: c93aa0f0c4037b3191cf28b74bdf0aeb5aff8ff827a0465acfc7976b37820a05
5
5
  SHA512:
6
- metadata.gz: 58f64b76e0e01b9489968297a9c2f470906009d05820895e76c4263b9ddc68d8b4f27c061db2f20cb5862855073f32337d84ae9b925670c78cff738bd7d48e67
7
- data.tar.gz: 832266dd39cd8b727e3e500c91c63377fa1b634c083f33a065cb005f6503bd0799d46b66627f374c4b1fecc0264ddf54843067ea0a7997bc0a536c35b0f7190a
6
+ metadata.gz: b0d4b08b17021a74a960ff3c75584c66668308944a6c7cf019599a69bdc06fc8493f9d2fefa7f21373ada19036f594fb038b2a004c8219589ed85a109bf5a6f5
7
+ data.tar.gz: 27600e93f884f1f48d8088b0d0421305c027ab78272cc26fe1b57cebf65d7e9a7aba4e66d7508fe0aef112803245a7acd788819e14f30dcb90a05c7cfaef3862
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.0.0 (2025-01-22)
6
+ ### Breaking Changes
7
+
8
+ * [#e2b27fa](https://github.com/ivan05almeida/easy_changelog/commit/e2b27fa): Add loose type mapping. ([@ivan05almeida][])
9
+
10
+ ## 0.4.0 (2025-01-22)
11
+ ### New features
12
+
13
+ * [#51e9888](https://github.com/ivan05almeida/easy_changelog/commit/51e9888): Allow user option. ([@ivan05almeida][])
14
+
5
15
  ## 0.3.2 (2025-01-22)
6
16
  ### Bug fixes
7
17
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_changelog (0.3.2)
4
+ easy_changelog (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -22,7 +22,7 @@ class EasyChangelog
22
22
  @filename_max_length = 50
23
23
  @type_mapping = {
24
24
  breaking: { title: 'Breaking Changes', level: :major },
25
- new: { title: 'New features', level: :minor },
25
+ feature: { title: 'New features', level: :minor },
26
26
  fix: { title: 'Bug fixes', level: :patch }
27
27
  }
28
28
  @include_empty_task_id = false
@@ -66,11 +66,15 @@ class EasyChangelog
66
66
  end
67
67
 
68
68
  def type_mapping=(value)
69
- raise ArgumentError, 'type_mapping must be a Hash' unless value.is_a?(Hash)
69
+ raise ArgumentError, 'type_mapping must be a Hash or :loose' unless value.is_a?(Hash) || value == :loose
70
70
 
71
71
  @type_mapping = value
72
72
  end
73
73
 
74
+ def loose?
75
+ @type_mapping == :loose
76
+ end
77
+
74
78
  def user_signature=(value)
75
79
  raise ArgumentError, 'user_signature must be a Regexp' unless value.is_a?(Regexp) || value.nil?
76
80
 
@@ -78,14 +82,20 @@ class EasyChangelog
78
82
  end
79
83
 
80
84
  def changelog_types
85
+ return [] if @type_mapping == :loose
86
+
81
87
  @type_mapping.keys
82
88
  end
83
89
 
84
90
  def sections
91
+ return [''] if @type_mapping == :loose
92
+
85
93
  @type_mapping.values.map { |v| v[:title] }
86
94
  end
87
95
 
88
96
  def section_for(type)
97
+ return '' if @type_mapping == :loose
98
+
89
99
  @type_mapping[type][:title]
90
100
  end
91
101
 
@@ -11,6 +11,7 @@ class EasyChangelog
11
11
 
12
12
  opts.banner = "Usage: rake changelog:#{type} [options]"
13
13
 
14
+ opts.on('-u', '--user=ARG', 'Git Username') { |arg| options[:user] = arg }
14
15
  opts.on('-b', '--body=ARG', 'Changelog Body Entry') { |arg| options[:body] = arg }
15
16
  opts.on('-r', '--ref-id=ARG', 'Ref ID') { |arg| options[:ref_id] = arg }
16
17
  opts.on('-R', '--ref-type=ARG', 'Ref type (issues|pull|commit)') { |arg| options[:ref_type] = arg }
@@ -23,6 +23,19 @@ namespace :changelog do
23
23
  end
24
24
  end
25
25
 
26
+ desc 'Create a Changelog entry (default)'
27
+ task :new do
28
+ environment
29
+ options = EasyChangelog::TaskOptionsParser.parse(:new, ARGV)
30
+ options[:type] = :new
31
+
32
+ entry = EasyChangelog::Entry.new(**options)
33
+ path = entry.write
34
+ cmd = "git add #{path}"
35
+ sh cmd
36
+ puts "Entry '#{path}' created and added to git index"
37
+ end
38
+
26
39
  desc 'Merge entries and delete them'
27
40
  task :merge do
28
41
  environment
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class EasyChangelog
4
- VERSION = '0.3.2'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -81,7 +81,13 @@ class EasyChangelog
81
81
  def unreleased_content
82
82
  entry_map = parse_entries(@entries)
83
83
  merged_map = merge_entries(entry_map)
84
- merged_map.flat_map { |header, things| ["### #{header}\n", *things, ''] }.join("\n")
84
+ merged_map.flat_map do |header, things|
85
+ if header.empty?
86
+ [*things, '']
87
+ else
88
+ ["### #{header}\n", *things, '']
89
+ end
90
+ end.join("\n")
85
91
  end
86
92
 
87
93
  def merge_content
@@ -142,14 +148,11 @@ class EasyChangelog
142
148
 
143
149
  # @return [Hash<type, Array<String>]]
144
150
  def parse_release(unreleased)
145
- unreleased
146
- .lines
147
- .map(&:chomp)
148
- .reject(&:empty?)
149
- .slice_before(HEADER)
150
- .to_h do |header, *entries|
151
- [HEADER.match(header)[1], entries]
152
- end
151
+ entries = unreleased.lines.map(&:chomp).reject(&:empty?)
152
+
153
+ return { '' => entries } if EasyChangelog.configuration.loose?
154
+
155
+ entries.slice_before(HEADER).to_h { |header, *header_entries| [HEADER.match(header)[1], header_entries] }
153
156
  end
154
157
 
155
158
  def parse_entries(path_content_map)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan de Paula Almeida Filho