reissue 0.4.0 → 0.4.1
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 +4 -4
- data/CHANGELOG.md +12 -10
- data/README.md +83 -85
- data/Rakefile +1 -0
- data/lib/reissue/changelog_updater.rb +19 -4
- data/lib/reissue/fragment_reader.rb +53 -0
- data/lib/reissue/rake.rb +64 -5
- data/lib/reissue/version.rb +1 -1
- data/lib/reissue.rb +39 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c53bf3bbfdb9cb767ee2e1faf924fac9b46bd0e08a1d98488e4518b7927c44a
|
4
|
+
data.tar.gz: 2c76b7c27045c90cbeae7a638d493cd8d2f06a7a0471ae15ef4bcc9552681aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e459e8d268410a615181abde6c74e78180360e3b14854987603ccf38d2dda205e4f847ee36272d1b78e9e7f3c21d66d8434ea4fac77aa915f31ff978d3dddc27
|
7
|
+
data.tar.gz: c689c1b58e0bcd081f64c51af1c7f3b310909834f9c87026d648ea7a4f1d102d0ba45eb886e45c4bd8ada0096a8a2c8388c1020c77139f82308eee661ae20f87
|
data/CHANGELOG.md
CHANGED
@@ -5,20 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
-
## [0.4.
|
9
|
-
|
10
|
-
### Changed
|
8
|
+
## [0.4.1] - 2025-08-18
|
11
9
|
|
12
|
-
|
10
|
+
### Added
|
13
11
|
|
14
|
-
|
12
|
+
- Add GitHub Actions workflow to release gems with Reissue
|
13
|
+
- Add `reissue:clear_fragments` task to clear fragments after release
|
15
14
|
|
16
|
-
|
15
|
+
### Changed
|
17
16
|
|
18
|
-
|
17
|
+
- Update README to clarify information about typical usage
|
18
|
+
- Updated the shared gem release workflow to work with hyphenated gem names.
|
19
|
+
- Rely on `rubygems/configure-rubygems-credentials` action.
|
19
20
|
|
20
|
-
-
|
21
|
+
## [0.4.0] - 2025-05-08
|
21
22
|
|
22
|
-
###
|
23
|
+
### Changed
|
23
24
|
|
24
|
-
-
|
25
|
+
- Update reformat task to create a new changelog if it doesn't exist
|
26
|
+
- Update the `reissue:branch` task to force create a new branch if it already exists.
|
data/README.md
CHANGED
@@ -1,142 +1,140 @@
|
|
1
1
|
# Reissue
|
2
2
|
|
3
|
-
|
3
|
+
Automate your Ruby gem releases with proper versioning and changelog management.
|
4
4
|
|
5
|
-
|
5
|
+
Keep your version numbers and changelogs consistent and up-to-date with minimal effort.
|
6
6
|
|
7
|
-
|
8
|
-
to capture the information about new changes.
|
7
|
+
## Bottom Line Up Front
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
When releasing gems, you typically run `rake build:checksum` to build the gem and generate the checksum,
|
10
|
+
then `rake release` to push the `.gem` file to [rubygems.org](https://rubygems.org).
|
12
11
|
|
13
|
-
|
12
|
+
With Reissue, the process remains the same, but you get automatic version bumping and changelog management included.
|
14
13
|
|
15
|
-
|
14
|
+
Also supports non-gem Ruby projects.
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
## How It Works
|
17
|
+
|
18
|
+
The workflow:
|
19
|
+
|
20
|
+
1. Start with a version number (e.g., 0.1.0) for your unreleased project.
|
21
|
+
2. Make commits and develop features.
|
22
|
+
3. Release the version, finalizing the changelog with the release date.
|
23
|
+
4. Reissue automatically bumps to the next version (e.g., 0.1.1) and prepares the changelog for future changes.
|
24
|
+
|
25
|
+
After each release, Reissue handles the version bump and changelog updates, so you're immediately ready for the next development cycle.
|
23
26
|
|
24
27
|
## Installation
|
25
28
|
|
26
|
-
|
29
|
+
Add to your application's Gemfile:
|
27
30
|
|
28
31
|
$ bundle add reissue
|
29
32
|
|
30
|
-
|
33
|
+
Or install directly:
|
31
34
|
|
32
35
|
$ gem install reissue
|
33
36
|
|
34
37
|
## Usage
|
35
38
|
|
36
|
-
|
39
|
+
### Gem Projects
|
40
|
+
|
41
|
+
Add to your Rakefile:
|
37
42
|
|
38
43
|
```ruby
|
39
44
|
require "reissue/gem"
|
40
45
|
|
41
46
|
Reissue::Task.create :reissue do |task|
|
42
|
-
# Required:
|
47
|
+
# Required: Path to your version file
|
43
48
|
task.version_file = "lib/my_gem/version.rb"
|
44
49
|
end
|
45
50
|
```
|
46
51
|
|
47
|
-
This
|
48
|
-
|
49
|
-
- `rake
|
50
|
-
version segment.
|
51
|
-
- `rake reissue:finalize[date]` - Update the CHANGELOG.md file with a date for
|
52
|
-
the latest version.
|
53
|
-
- `rake reissue:reformat[version_limit]` - Reformat the CHANGELOG.md file and
|
54
|
-
optionally limit the number of versions to maintain.
|
55
|
-
- `rake reissue:branch[branch-name]` - Create a new branch for the next version.
|
56
|
-
Controlled by the `push_finalize` and `commit_finalize` options.
|
57
|
-
- `rake reissue:push` - Push the changes to the remote repository. Controlled
|
58
|
-
by the `push_finalize` and `commit_finalize` options.
|
59
|
-
|
60
|
-
This will also update the `build` task from rubygems to first run
|
61
|
-
`reissue:finalize` and then build the gem, ensuring that your changelog is
|
62
|
-
up-to-date before the gem is built.
|
52
|
+
This integrates with standard gem tasks:
|
53
|
+
- `rake build` - Now finalizes the changelog before building
|
54
|
+
- `rake release` - Automatically bumps version after release
|
63
55
|
|
64
|
-
|
65
|
-
|
56
|
+
Additional tasks (usually run automatically):
|
57
|
+
- `rake reissue[segment]` - Bump version (major, minor, patch)
|
58
|
+
- `rake reissue:finalize[date]` - Add release date to changelog
|
59
|
+
- `rake reissue:reformat[version_limit]` - Clean up changelog formatting
|
60
|
+
- `rake reissue:clear_fragments` - Clear changelog fragments after release
|
66
61
|
|
67
|
-
|
62
|
+
### Non-Gem Projects
|
68
63
|
|
69
|
-
|
64
|
+
For non-gem Ruby projects, add to your Rakefile:
|
70
65
|
|
71
66
|
```ruby
|
72
67
|
require "reissue/rake"
|
73
68
|
|
74
69
|
Reissue::Task.create :reissue do |task|
|
75
|
-
# Required: The file to update with the new version number.
|
76
70
|
task.version_file = "path/to/version.rb"
|
77
71
|
end
|
78
72
|
```
|
79
73
|
|
80
|
-
|
74
|
+
Then use the rake tasks to manage your releases.
|
81
75
|
|
82
|
-
|
83
|
-
require "reissue/rake"
|
84
|
-
|
85
|
-
Reissue::Task.create :your_name_and_namespace do |task|
|
76
|
+
### Configuration Options
|
86
77
|
|
87
|
-
|
88
|
-
task.name = "your_name_and_namespace"
|
89
|
-
|
90
|
-
# Optional: The description of the main task.
|
91
|
-
task.description = "Prepare the next version of the gem."
|
92
|
-
|
93
|
-
# Required: The file to update with the new version number.
|
94
|
-
task.version_file = "path/to/version.rb"
|
78
|
+
All available configuration options:
|
95
79
|
|
96
|
-
|
80
|
+
```ruby
|
81
|
+
Reissue::Task.create :reissue do |task|
|
82
|
+
# Required: The file to update with the new version number
|
83
|
+
task.version_file = "lib/my_gem/version.rb"
|
84
|
+
|
85
|
+
# Optional: The name of the task. Defaults to "reissue"
|
86
|
+
task.name = "reissue"
|
87
|
+
|
88
|
+
# Optional: The description of the main task
|
89
|
+
task.description = "Prepare the next version of the gem"
|
90
|
+
|
91
|
+
# Optional: The changelog file to update. Defaults to "CHANGELOG.md"
|
92
|
+
task.changelog_file = "CHANGELOG.md"
|
93
|
+
|
94
|
+
# Optional: The number of versions to maintain in the changelog. Defaults to 2
|
97
95
|
task.version_limit = 5
|
98
|
-
|
99
|
-
# Optional:
|
96
|
+
|
97
|
+
# Optional: Whether to commit the changes automatically. Defaults to true
|
98
|
+
task.commit = true
|
99
|
+
|
100
|
+
# Optional: Whether to commit the results of the finalize task. Defaults to true
|
101
|
+
task.commit_finalize = true
|
102
|
+
|
103
|
+
# Optional: Whether to push the changes automatically. Defaults to false
|
104
|
+
# Options: false, true (push working branch), :branch (create and push new branch)
|
105
|
+
task.push_finalize = :branch
|
106
|
+
|
107
|
+
# Optional: Directory containing fragment files for changelog entries. Defaults to nil (disabled)
|
108
|
+
task.fragment_directory = "changelog_fragments"
|
109
|
+
|
110
|
+
# Optional: Whether to clear fragment files after releasing. Defaults to false
|
111
|
+
# When true, fragments are cleared after a release
|
112
|
+
task.clear_fragments = true
|
113
|
+
|
114
|
+
# Optional: Retain changelog files for previous versions. Defaults to false
|
115
|
+
# Options: true (retain in "changelogs" directory), "path/to/archive", or a Proc
|
116
|
+
task.retain_changelogs = true
|
117
|
+
# task.retain_changelogs = "path/to/archive"
|
118
|
+
# task.retain_changelogs = ->(version, content) { # custom logic }
|
119
|
+
|
120
|
+
# Optional: Custom version formatting logic. Receives a Gem::Version object and segment
|
100
121
|
task.version_redo_proc = ->(version, segment) do
|
101
122
|
# your special versioning logic
|
123
|
+
version.bump
|
102
124
|
end
|
103
|
-
|
104
|
-
# Optional: The file to update with the new version number. Defaults to "CHANGELOG.md".
|
105
|
-
task.changelog_file = "path/to/CHANGELOG.md"
|
106
|
-
|
107
|
-
# Optional: A Boolean, String, or Proc to retain the changelog files for the previous versions. Defaults to false.
|
108
|
-
# Setting to true will retain the changelog files in the "changelogs" directory.
|
109
|
-
# Setting to a String will use that path as the directory to retain the changelog files.
|
110
|
-
# The Proc receives a version hash and the changelog content.
|
111
|
-
task.retain_changelogs = ->(version, content) do
|
112
|
-
# your special retention logic
|
113
|
-
end
|
114
|
-
# or task.retain_changelogs = "path/to/changelogs"
|
115
|
-
# or task.retain_changelogs = true
|
116
|
-
|
117
|
-
# Optional: Whether to commit the changes automatically. Defaults to true.
|
118
|
-
task.commit = false
|
119
|
-
|
120
|
-
# Optional: Whether or not to commit the results of the finalize task. Defaults to true.
|
121
|
-
task.commit_finalize = false
|
122
|
-
|
123
|
-
# Optional: Whether to push the changes automatically. Defaults to false.
|
124
|
-
task.push_finalize = :branch # or false, or true to push the working branch
|
125
125
|
end
|
126
126
|
```
|
127
127
|
|
128
128
|
## Development
|
129
129
|
|
130
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then
|
131
|
-
|
132
|
-
## Releasing
|
133
|
-
|
134
|
-
Run `rake build:checksum` to build the gem and generate the checksum. This will also update the version number in the gemspec file.
|
130
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt.
|
135
131
|
|
136
|
-
|
132
|
+
## Releasing This Gem
|
137
133
|
|
138
|
-
|
139
|
-
|
134
|
+
1. Run `rake build:checksum` to build the gem and generate checksums
|
135
|
+
2. Run `rake release` to push to [rubygems.org](https://rubygems.org)
|
136
|
+
3. The version will automatically bump and the changelog will be updated
|
137
|
+
4. Push the changes to the repository
|
140
138
|
|
141
139
|
## Contributing
|
142
140
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "parser"
|
2
2
|
require_relative "printer"
|
3
|
+
require_relative "fragment_reader"
|
3
4
|
|
4
5
|
module Reissue
|
5
6
|
# Updates the changelog file with new versions and changes.
|
@@ -18,9 +19,11 @@ module Reissue
|
|
18
19
|
# @param changes [Hash] The changes for the version (default: {}).
|
19
20
|
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
20
21
|
# @param version_limit [Integer] The number of versions to keep (default: 2).
|
21
|
-
|
22
|
-
|
22
|
+
# @param fragment_directory [String] The directory containing fragment files (default: nil).
|
23
|
+
def call(version, date: "Unreleased", changes: {}, changelog_file: @changelog_file, version_limit: 2, retain_changelogs: false, fragment_directory: nil)
|
24
|
+
update(version, date:, changes:, version_limit:, fragment_directory:)
|
23
25
|
write(changelog_file, retain_changelogs:)
|
26
|
+
|
24
27
|
changelog
|
25
28
|
end
|
26
29
|
|
@@ -45,11 +48,23 @@ module Reissue
|
|
45
48
|
# @param date [String] The release date (default: "Unreleased").
|
46
49
|
# @param changes [Hash] The changes for the version (default: {}).
|
47
50
|
# @param version_limit [Integer] The number of versions to keep (default: 2).
|
51
|
+
# @param fragment_directory [String] The directory containing fragment files (default: nil).
|
48
52
|
# @return [Hash] The updated changelog.
|
49
|
-
def update(version, date: "Unreleased", changes: {}, version_limit: 2)
|
53
|
+
def update(version, date: "Unreleased", changes: {}, version_limit: 2, fragment_directory: nil)
|
50
54
|
@changelog = Parser.parse(File.read(@changelog_file))
|
51
55
|
|
52
|
-
|
56
|
+
# Merge fragment changes if directory is provided
|
57
|
+
merged_changes = changes.dup
|
58
|
+
if fragment_directory
|
59
|
+
fragment_reader = FragmentReader.new(fragment_directory)
|
60
|
+
fragment_changes = fragment_reader.read
|
61
|
+
fragment_changes.each do |section, entries|
|
62
|
+
merged_changes[section] ||= []
|
63
|
+
merged_changes[section].concat(entries)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
changelog["versions"].unshift({"version" => version, "date" => date, "changes" => merged_changes})
|
53
68
|
changelog["versions"] = changelog["versions"].first(version_limit)
|
54
69
|
changelog
|
55
70
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module Reissue
|
4
|
+
class FragmentReader
|
5
|
+
DEFAULT_VALID_SECTIONS = %w[added changed deprecated removed fixed security].freeze
|
6
|
+
|
7
|
+
def initialize(fragment_directory = "changelog.d", valid_sections: DEFAULT_VALID_SECTIONS)
|
8
|
+
@fragment_directory = Pathname.new(fragment_directory)
|
9
|
+
@valid_sections = valid_sections
|
10
|
+
end
|
11
|
+
|
12
|
+
def read
|
13
|
+
return {} unless @fragment_directory.exist?
|
14
|
+
|
15
|
+
fragments = {}
|
16
|
+
|
17
|
+
@fragment_directory.glob("*.*.md").each do |fragment_file|
|
18
|
+
filename = fragment_file.basename.to_s
|
19
|
+
parts = filename.split(".")
|
20
|
+
|
21
|
+
next unless parts.length == 3
|
22
|
+
|
23
|
+
section = parts[1].downcase
|
24
|
+
next unless valid_section?(section)
|
25
|
+
|
26
|
+
content = fragment_file.read.strip
|
27
|
+
next if content.empty?
|
28
|
+
|
29
|
+
# Capitalize section name for changelog format
|
30
|
+
section_key = section.capitalize
|
31
|
+
fragments[section_key] ||= []
|
32
|
+
fragments[section_key] << content
|
33
|
+
end
|
34
|
+
|
35
|
+
fragments
|
36
|
+
end
|
37
|
+
|
38
|
+
def clear
|
39
|
+
return unless @fragment_directory.exist?
|
40
|
+
|
41
|
+
@fragment_directory.glob("*.*.md").each(&:delete)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def valid_section?(section)
|
47
|
+
return true if @valid_sections.nil?
|
48
|
+
return false unless @valid_sections.is_a?(Array)
|
49
|
+
|
50
|
+
@valid_sections.map(&:downcase).include?(section.downcase)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/reissue/rake.rb
CHANGED
@@ -36,6 +36,14 @@ module Reissue
|
|
36
36
|
# Provide a callable to decide how to store the files.
|
37
37
|
attr_accessor :retain_changelogs
|
38
38
|
|
39
|
+
# The directory containing fragment files for changelog entries.
|
40
|
+
# Default: nil (disabled).
|
41
|
+
attr_accessor :fragment_directory
|
42
|
+
|
43
|
+
# Whether to clear fragment files after processing.
|
44
|
+
# Default: false.
|
45
|
+
attr_accessor :clear_fragments
|
46
|
+
|
39
47
|
# Additional paths to add to the commit.
|
40
48
|
attr_writer :updated_paths
|
41
49
|
|
@@ -49,6 +57,9 @@ module Reissue
|
|
49
57
|
# Whether to commit the finalize change to the changelog. Default: true.
|
50
58
|
attr_accessor :commit_finalize
|
51
59
|
|
60
|
+
# Whether to commit the clear fragments change. Default: true.
|
61
|
+
attr_accessor :commit_clear_fragments
|
62
|
+
|
52
63
|
# Whether to branch and push the changes. Default: :branch.
|
53
64
|
# Requires commit_finialize to be true.
|
54
65
|
#
|
@@ -74,8 +85,11 @@ module Reissue
|
|
74
85
|
@updated_paths = []
|
75
86
|
@changelog_file = "CHANGELOG.md"
|
76
87
|
@retain_changelogs = false
|
88
|
+
@fragment_directory = nil
|
89
|
+
@clear_fragments = false
|
77
90
|
@commit = true
|
78
91
|
@commit_finalize = true
|
92
|
+
@commit_clear_fragments = true
|
79
93
|
@push_finalize = false
|
80
94
|
@version_limit = 2
|
81
95
|
@version_redo_proc = nil
|
@@ -113,9 +127,17 @@ module Reissue
|
|
113
127
|
desc description
|
114
128
|
task name, [:segment] do |task, args|
|
115
129
|
segment = args[:segment] || "patch"
|
116
|
-
new_version = formatter.call(
|
130
|
+
new_version = formatter.call(
|
131
|
+
segment:,
|
132
|
+
version_file:,
|
133
|
+
version_limit:,
|
134
|
+
version_redo_proc:,
|
135
|
+
fragment_directory:
|
136
|
+
)
|
117
137
|
bundle
|
118
138
|
|
139
|
+
tasker["#{name}:clear_fragments"].invoke
|
140
|
+
|
119
141
|
system("git add -u")
|
120
142
|
if updated_paths&.any?
|
121
143
|
system("git add #{updated_paths.join(" ")}")
|
@@ -151,10 +173,17 @@ module Reissue
|
|
151
173
|
desc "Finalize the changelog for an unreleased version to set the release date."
|
152
174
|
task "#{name}:finalize", [:date] do |task, args|
|
153
175
|
date = args[:date] || Time.now.strftime("%Y-%m-%d")
|
154
|
-
version, date = formatter.finalize(
|
176
|
+
version, date = formatter.finalize(
|
177
|
+
date,
|
178
|
+
changelog_file:,
|
179
|
+
retain_changelogs:,
|
180
|
+
fragment_directory:
|
181
|
+
)
|
155
182
|
finalize_message = "Finalize the changelog for version #{version} on #{date}"
|
156
183
|
if commit_finalize
|
157
|
-
|
184
|
+
if finalize_with_branch?
|
185
|
+
tasker["#{name}:branch"].invoke("reissue/#{version}")
|
186
|
+
end
|
158
187
|
system("git add -u")
|
159
188
|
system("git commit -m '#{finalize_message}'")
|
160
189
|
tasker["#{name}:push"].invoke if push_finalize?
|
@@ -163,16 +192,46 @@ module Reissue
|
|
163
192
|
end
|
164
193
|
end
|
165
194
|
|
166
|
-
desc
|
195
|
+
desc <<~MSG
|
196
|
+
Create a new branch for the next version.
|
197
|
+
|
198
|
+
If the branch already exists it will be deleted and a new one will be created along with a new tag.
|
199
|
+
MSG
|
200
|
+
|
167
201
|
task "#{name}:branch", [:branch_name] do |task, args|
|
168
202
|
raise "No branch name specified" unless args[:branch_name]
|
169
|
-
|
203
|
+
branch_name = args[:branch_name]
|
204
|
+
# Force create branch by deleting if exists, then creating fresh
|
205
|
+
if system("git show-ref --verify --quiet refs/heads/#{branch_name}")
|
206
|
+
# Extract version from branch name (e.g., "reissue/0.4.1" -> "0.4.1")
|
207
|
+
version = branch_name.sub(/^reissue\//, "")
|
208
|
+
# Delete matching tag if it exists
|
209
|
+
system("git tag -d v#{version} 2>/dev/null || true")
|
210
|
+
# Delete the branch
|
211
|
+
system("git branch -D #{branch_name}")
|
212
|
+
end
|
213
|
+
system("git checkout -b #{branch_name}")
|
170
214
|
end
|
171
215
|
|
172
216
|
desc "Push the current branch to the remote repository."
|
173
217
|
task "#{name}:push" do
|
174
218
|
system("git push origin HEAD")
|
175
219
|
end
|
220
|
+
|
221
|
+
desc "Clear fragments"
|
222
|
+
task "#{name}:clear_fragments" do
|
223
|
+
# Clear fragments after release if configured
|
224
|
+
if fragment_directory && clear_fragments
|
225
|
+
formatter.clear_fragments(fragment_directory)
|
226
|
+
clear_message = "Clear changelog fragments"
|
227
|
+
if commit_clear_fragments
|
228
|
+
system("git add #{fragment_directory}")
|
229
|
+
system("git commit -m '#{clear_message}'")
|
230
|
+
else
|
231
|
+
system("echo '#{clear_message}'")
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
176
235
|
end
|
177
236
|
end
|
178
237
|
end
|
data/lib/reissue/version.rb
CHANGED
data/lib/reissue.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative "reissue/version"
|
4
4
|
require_relative "reissue/version_updater"
|
5
5
|
require_relative "reissue/changelog_updater"
|
6
|
+
require_relative "reissue/fragment_reader"
|
6
7
|
|
7
8
|
# Reissue is a module that provides functionality for updating version numbers and changelogs.
|
8
9
|
module Reissue
|
@@ -14,6 +15,7 @@ module Reissue
|
|
14
15
|
# @param date [String] The release date. Default: Unreleased
|
15
16
|
# @param changes [Hash] The changes made in this release. Default: {}
|
16
17
|
# @param version_limit [Integer] The number of versions to retain in the changes. Default: 2
|
18
|
+
# @param fragment_directory [String] The directory containing fragment files. Default: nil
|
17
19
|
#
|
18
20
|
# @return [String] The new version number.
|
19
21
|
def self.call(
|
@@ -24,13 +26,14 @@ module Reissue
|
|
24
26
|
date: "Unreleased",
|
25
27
|
changes: {},
|
26
28
|
version_limit: 2,
|
27
|
-
version_redo_proc: nil
|
29
|
+
version_redo_proc: nil,
|
30
|
+
fragment_directory: nil
|
28
31
|
)
|
29
32
|
version_updater = VersionUpdater.new(version_file, version_redo_proc:)
|
30
33
|
new_version = version_updater.call(segment, version_file:)
|
31
34
|
if changelog_file
|
32
35
|
changelog_updater = ChangelogUpdater.new(changelog_file)
|
33
|
-
changelog_updater.call(new_version, date:, changes:, changelog_file:, version_limit:, retain_changelogs:)
|
36
|
+
changelog_updater.call(new_version, date:, changes:, changelog_file:, version_limit:, retain_changelogs:, fragment_directory:)
|
34
37
|
end
|
35
38
|
new_version
|
36
39
|
end
|
@@ -39,11 +42,34 @@ module Reissue
|
|
39
42
|
#
|
40
43
|
# @param date [String] The release date.
|
41
44
|
# @param changelog_file [String] The path to the changelog file.
|
45
|
+
# @param fragment_directory [String] The directory containing fragment files. Default: nil
|
42
46
|
#
|
43
47
|
# @return [Array] The version number and release date.
|
44
|
-
def self.finalize(date = Date.today, changelog_file: "CHANGELOG.md", retain_changelogs: false)
|
48
|
+
def self.finalize(date = Date.today, changelog_file: "CHANGELOG.md", retain_changelogs: false, fragment_directory: nil)
|
45
49
|
changelog_updater = ChangelogUpdater.new(changelog_file)
|
50
|
+
|
51
|
+
# If fragments are present, we need to update the unreleased version with them first
|
52
|
+
if fragment_directory
|
53
|
+
# Get the current changelog to find the unreleased version
|
54
|
+
changelog = Parser.parse(File.read(changelog_file))
|
55
|
+
unreleased_version = changelog["versions"].find { |v| v["date"] == "Unreleased" }
|
56
|
+
|
57
|
+
if unreleased_version
|
58
|
+
# Update with fragment data
|
59
|
+
changelog_updater.update(
|
60
|
+
unreleased_version["version"],
|
61
|
+
date: "Unreleased",
|
62
|
+
changes: unreleased_version["changes"] || {},
|
63
|
+
fragment_directory: fragment_directory,
|
64
|
+
version_limit: changelog["versions"].size
|
65
|
+
)
|
66
|
+
changelog_updater.write(changelog_file, retain_changelogs: false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Now finalize with the date
|
46
71
|
changelog = changelog_updater.finalize(date:, changelog_file:, retain_changelogs:)
|
72
|
+
|
47
73
|
changelog["versions"].first.slice("version", "date").values
|
48
74
|
end
|
49
75
|
|
@@ -86,4 +112,14 @@ module Reissue
|
|
86
112
|
retain_changelogs: false
|
87
113
|
)
|
88
114
|
end
|
115
|
+
|
116
|
+
# Clears all fragment files in the specified directory.
|
117
|
+
#
|
118
|
+
# @param fragment_directory [String] The directory containing fragment files.
|
119
|
+
def self.clear_fragments(fragment_directory)
|
120
|
+
return unless fragment_directory && Dir.exist?(fragment_directory)
|
121
|
+
|
122
|
+
fragment_reader = FragmentReader.new(fragment_directory)
|
123
|
+
fragment_reader.clear
|
124
|
+
end
|
89
125
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reissue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- lib/reissue.rb
|
38
38
|
- lib/reissue/changelog_updater.rb
|
39
|
+
- lib/reissue/fragment_reader.rb
|
39
40
|
- lib/reissue/gem.rb
|
40
41
|
- lib/reissue/markdown.rb
|
41
42
|
- lib/reissue/parser.rb
|