reissue 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -9
- data/README.md +10 -0
- data/Rakefile +1 -1
- data/lib/reissue/changelog_updater.rb +35 -8
- data/lib/reissue/rake.rb +51 -15
- data/lib/reissue/version.rb +1 -1
- data/lib/reissue.rb +5 -3
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6ac7b4c6d82f57ed9e9733bfa072344ea79c3b5075aaf4789f40815be528ebd
|
4
|
+
data.tar.gz: a6eb54ae8e1037521b227f21869853292339c1b189e5ad8f060e62e044fdeaa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2481e4f823168b94f3374e97a3e2c55b7e394e4110c5fdd9cf8b4635b2919049e22de219f07d9efac7ec62168a97bc50a83227b30cad7fe5b8830268d95a43ca
|
7
|
+
data.tar.gz: 9ca6fa4a75c7c9037f4289febae72552b777fb31fe5576a349fcd8f608c350d89e9f6beb4a66662e298afb67c2ee2bef44cc81a5a86be57ef04486f5a8a4d2ed
|
data/CHANGELOG.md
CHANGED
@@ -5,24 +5,24 @@ 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.
|
8
|
+
## [0.3.1] - 2025-01-16
|
9
9
|
|
10
10
|
### Added
|
11
11
|
|
12
|
-
- Add
|
13
|
-
- Add a `reissue:push` task to push the new branch to the remote repository
|
12
|
+
- Add `retain_changelogs` option to control how to retain the changelog files for the previous versions.
|
14
13
|
|
15
|
-
###
|
14
|
+
### Changed
|
16
15
|
|
17
|
-
-
|
18
|
-
-
|
16
|
+
- Set the name of the `reissue:branch` argument to `branch_name` to be clearer.
|
17
|
+
- Inject the constants in the `create` method.
|
18
|
+
- Updated the tested Ruby version to 3.4.
|
19
19
|
|
20
|
-
## [0.
|
20
|
+
## [0.3.0] - 2024-09-06
|
21
21
|
|
22
22
|
### Added
|
23
23
|
|
24
|
-
-
|
24
|
+
- Add `push_reissue` option to control pushing changes to the remote repository.
|
25
25
|
|
26
26
|
### Changed
|
27
27
|
|
28
|
-
-
|
28
|
+
- Default behavior of _this_ gem's release is to push finalize without a branch.
|
data/README.md
CHANGED
@@ -104,6 +104,16 @@ Reissue::Task.create :your_name_and_namespace do |task|
|
|
104
104
|
# Optional: The file to update with the new version number. Defaults to "CHANGELOG.md".
|
105
105
|
task.changelog_file = "path/to/CHANGELOG.md"
|
106
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
|
+
|
107
117
|
# Optional: Whether to commit the changes automatically. Defaults to true.
|
108
118
|
task.commit = false
|
109
119
|
|
data/Rakefile
CHANGED
@@ -18,23 +18,24 @@ module Reissue
|
|
18
18
|
# @param changes [Hash] The changes for the version (default: {}).
|
19
19
|
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
20
20
|
# @param version_limit [Integer] The number of versions to keep (default: 2).
|
21
|
-
def call(version, date: "Unreleased", changes: {}, changelog_file: @changelog_file, version_limit: 2)
|
21
|
+
def call(version, date: "Unreleased", changes: {}, changelog_file: @changelog_file, version_limit: 2, retain_changelogs: false)
|
22
22
|
update(version, date:, changes:, version_limit:)
|
23
|
-
write(changelog_file)
|
23
|
+
write(changelog_file, retain_changelogs:)
|
24
24
|
changelog
|
25
25
|
end
|
26
26
|
|
27
|
-
def finalize(date: Date.today, changelog_file: @changelog_file)
|
27
|
+
def finalize(date: Date.today, changelog_file: @changelog_file, retain_changelogs: false)
|
28
28
|
@changelog = Parser.parse(File.read(changelog_file))
|
29
|
+
|
29
30
|
# find the highest version number and if it is unreleased, update the date
|
30
|
-
version =
|
31
|
+
version = latest_version
|
31
32
|
version_date = version["date"]
|
32
33
|
if version_date.nil? || version_date == "Unreleased"
|
33
34
|
changelog["versions"].find do |v|
|
34
35
|
v["version"] == version["version"]
|
35
36
|
end["date"] = date
|
36
37
|
end
|
37
|
-
write
|
38
|
+
write(changelog_file, retain_changelogs:)
|
38
39
|
changelog
|
39
40
|
end
|
40
41
|
|
@@ -57,10 +58,10 @@ module Reissue
|
|
57
58
|
#
|
58
59
|
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
59
60
|
# @return [Hash] The parsed changelog.
|
60
|
-
def reformat(result_file = @changelog_file, version_limit: 2)
|
61
|
+
def reformat(result_file = @changelog_file, version_limit: 2, retain_changelogs: false)
|
61
62
|
@changelog = Parser.parse(File.read(@changelog_file))
|
62
63
|
changelog["versions"] = changelog["versions"].first(version_limit)
|
63
|
-
write(result_file)
|
64
|
+
write(result_file, retain_changelogs:)
|
64
65
|
changelog
|
65
66
|
end
|
66
67
|
|
@@ -74,8 +75,34 @@ module Reissue
|
|
74
75
|
# Writes the changelog to the specified file.
|
75
76
|
#
|
76
77
|
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
77
|
-
def write(changelog_file = @changelog_file)
|
78
|
+
def write(changelog_file = @changelog_file, retain_changelogs: false)
|
79
|
+
if retain_changelogs
|
80
|
+
store_current_changelog(latest_version, retain_changelogs)
|
81
|
+
end
|
78
82
|
File.write(changelog_file, to_s)
|
79
83
|
end
|
84
|
+
|
85
|
+
# Stores the current changelog in a file.
|
86
|
+
#
|
87
|
+
# @param version [Hash] The version information.
|
88
|
+
# @param path [String, Proc] The path to store the changelog or a callable that receives the version and the changelog.
|
89
|
+
def store_current_changelog(version, path)
|
90
|
+
if path
|
91
|
+
if path.respond_to?(:call)
|
92
|
+
path.call(version, to_s)
|
93
|
+
else
|
94
|
+
require "fileutils"
|
95
|
+
path = path.is_a?(String) ? path : "changelogs"
|
96
|
+
FileUtils.mkdir_p(path)
|
97
|
+
File.write("#{path}/#{version["version"]}.md", to_s)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def latest_version
|
105
|
+
changelog["versions"].max_by { |v| ::Gem::Version.new(v["version"]) }
|
106
|
+
end
|
80
107
|
end
|
81
108
|
end
|
data/lib/reissue/rake.rb
CHANGED
@@ -31,6 +31,11 @@ module Reissue
|
|
31
31
|
# The path to the changelog file.
|
32
32
|
attr_accessor :changelog_file
|
33
33
|
|
34
|
+
# Set to true to retain the changelog files for the previous versions.
|
35
|
+
# Default: false.
|
36
|
+
# Provide a callable to decide how to store the files.
|
37
|
+
attr_accessor :retain_changelogs
|
38
|
+
|
34
39
|
# Additional paths to add to the commit.
|
35
40
|
attr_writer :updated_paths
|
36
41
|
|
@@ -52,19 +57,34 @@ module Reissue
|
|
52
57
|
# Set this to :branch to push to a new branch.
|
53
58
|
attr_accessor :push_finalize
|
54
59
|
|
55
|
-
|
60
|
+
# Whether to push the changes when a new version is created. Default: :branch.
|
61
|
+
# Requires commit to be true.
|
62
|
+
#
|
63
|
+
# Set this to false to disable pushing.
|
64
|
+
# Set this to true to push to the current branch.
|
65
|
+
# Set this to :branch to push to a new branch.
|
66
|
+
attr_accessor :push_reissue
|
67
|
+
|
68
|
+
def initialize(name = :reissue, formatter: Reissue, tasker: Rake::Task)
|
56
69
|
@name = name
|
70
|
+
@formatter = formatter
|
71
|
+
@tasker = tasker
|
57
72
|
@description = "Prepare the code for work on a new version."
|
58
73
|
@version_file = nil
|
59
74
|
@updated_paths = []
|
60
75
|
@changelog_file = "CHANGELOG.md"
|
76
|
+
@retain_changelogs = false
|
61
77
|
@commit = true
|
62
78
|
@commit_finalize = true
|
63
79
|
@push_finalize = false
|
64
80
|
@version_limit = 2
|
65
81
|
@version_redo_proc = nil
|
82
|
+
@push_reissue = :branch
|
66
83
|
end
|
67
84
|
|
85
|
+
attr_reader :formatter, :tasker
|
86
|
+
private :formatter, :tasker
|
87
|
+
|
68
88
|
def finalize_with_branch?
|
69
89
|
push_finalize == :branch
|
70
90
|
end
|
@@ -73,25 +93,41 @@ module Reissue
|
|
73
93
|
!!push_finalize
|
74
94
|
end
|
75
95
|
|
96
|
+
def reissue_version_with_branch?
|
97
|
+
push_reissue == :branch
|
98
|
+
end
|
99
|
+
|
100
|
+
def push_reissue?
|
101
|
+
!!push_reissue
|
102
|
+
end
|
103
|
+
|
104
|
+
def bundle
|
105
|
+
if defined?(Bundler)
|
106
|
+
Bundler.with_unbundled_env do
|
107
|
+
system("bundle install")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
76
112
|
def define
|
77
113
|
desc description
|
78
114
|
task name, [:segment] do |task, args|
|
79
115
|
segment = args[:segment] || "patch"
|
80
|
-
new_version =
|
81
|
-
|
82
|
-
Bundler.with_unbundled_env do
|
83
|
-
system("bundle install")
|
84
|
-
end
|
85
|
-
end
|
116
|
+
new_version = formatter.call(segment:, version_file:, version_limit:, version_redo_proc:)
|
117
|
+
bundle
|
86
118
|
|
87
119
|
system("git add -u")
|
88
|
-
if updated_paths
|
120
|
+
if updated_paths&.any?
|
89
121
|
system("git add #{updated_paths.join(" ")}")
|
90
122
|
end
|
91
123
|
|
92
124
|
bump_message = "Bump version to #{new_version}"
|
93
125
|
if commit
|
126
|
+
if reissue_version_with_branch?
|
127
|
+
tasker["#{name}:branch"].invoke("reissue/#{new_version}")
|
128
|
+
end
|
94
129
|
system("git commit -m '#{bump_message}'")
|
130
|
+
tasker["#{name}:push"].invoke if push_reissue?
|
95
131
|
else
|
96
132
|
system("echo '#{bump_message}'")
|
97
133
|
end
|
@@ -106,28 +142,28 @@ module Reissue
|
|
106
142
|
else
|
107
143
|
args[:version_limit].to_i
|
108
144
|
end
|
109
|
-
|
145
|
+
formatter.reformat(changelog_file, version_limit:, retain_changelogs:)
|
110
146
|
end
|
111
147
|
|
112
148
|
desc "Finalize the changelog for an unreleased version to set the release date."
|
113
149
|
task "#{name}:finalize", [:date] do |task, args|
|
114
150
|
date = args[:date] || Time.now.strftime("%Y-%m-%d")
|
115
|
-
version, date =
|
151
|
+
version, date = formatter.finalize(date, changelog_file:)
|
116
152
|
finalize_message = "Finalize the changelog for version #{version} on #{date}"
|
117
153
|
if commit_finalize
|
118
|
-
|
154
|
+
tasker["#{name}:branch"].invoke("reissue/#{version}") if finalize_with_branch?
|
119
155
|
system("git add -u")
|
120
156
|
system("git commit -m '#{finalize_message}'")
|
121
|
-
|
157
|
+
tasker["#{name}:push"].invoke if push_finalize?
|
122
158
|
else
|
123
159
|
system("echo '#{finalize_message}'")
|
124
160
|
end
|
125
161
|
end
|
126
162
|
|
127
163
|
desc "Create a new branch for the next version."
|
128
|
-
task "#{name}:branch", [:
|
129
|
-
raise "No branch name specified" unless args[:
|
130
|
-
system("git checkout -b #{args[:
|
164
|
+
task "#{name}:branch", [:branch_name] do |task, args|
|
165
|
+
raise "No branch name specified" unless args[:branch_name]
|
166
|
+
system("git checkout -b #{args[:branch_name]}")
|
131
167
|
end
|
132
168
|
|
133
169
|
desc "Push the current branch to the remote repository."
|
data/lib/reissue/version.rb
CHANGED
data/lib/reissue.rb
CHANGED
@@ -19,6 +19,7 @@ module Reissue
|
|
19
19
|
def self.call(
|
20
20
|
version_file:,
|
21
21
|
changelog_file: "CHANGELOG.md",
|
22
|
+
retain_changelogs: false,
|
22
23
|
segment: "patch",
|
23
24
|
date: "Unreleased",
|
24
25
|
changes: {},
|
@@ -29,7 +30,7 @@ module Reissue
|
|
29
30
|
new_version = version_updater.call(segment, version_file:)
|
30
31
|
if changelog_file
|
31
32
|
changelog_updater = ChangelogUpdater.new(changelog_file)
|
32
|
-
changelog_updater.call(new_version, date:, changes:, changelog_file:, version_limit:)
|
33
|
+
changelog_updater.call(new_version, date:, changes:, changelog_file:, version_limit:, retain_changelogs:)
|
33
34
|
end
|
34
35
|
new_version
|
35
36
|
end
|
@@ -50,8 +51,9 @@ module Reissue
|
|
50
51
|
#
|
51
52
|
# @param file [String] The path to the changelog file.
|
52
53
|
# @param version_limit [Integer] The number of versions to retain in the changelog. Default: 2
|
53
|
-
|
54
|
+
# @param retain_changelogs [Boolean, String, Proc] Whether to retain the changelog files for the previous versions.
|
55
|
+
def self.reformat(file, version_limit: 2, retain_changelogs: false)
|
54
56
|
changelog_updater = ChangelogUpdater.new(file)
|
55
|
-
changelog_updater.reformat(version_limit:)
|
57
|
+
changelog_updater.reformat(version_limit:, retain_changelogs:)
|
56
58
|
end
|
57
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reissue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-16 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -50,7 +49,6 @@ metadata:
|
|
50
49
|
homepage_uri: https://github.com/SOFware/reissue
|
51
50
|
source_code_uri: https://github.com/SOFware/reissue
|
52
51
|
changelog_uri: https://github.com/SOFware/reissue/blob/main/CHANGELOG.md
|
53
|
-
post_install_message:
|
54
52
|
rdoc_options: []
|
55
53
|
require_paths:
|
56
54
|
- lib
|
@@ -65,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
63
|
- !ruby/object:Gem::Version
|
66
64
|
version: '0'
|
67
65
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
69
|
-
signing_key:
|
66
|
+
rubygems_version: 3.6.2
|
70
67
|
specification_version: 4
|
71
68
|
summary: Keep your versions and changelogs up to date and prepared for release.
|
72
69
|
test_files: []
|