gem_hadar 2.11.0 → 2.13.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 +4 -4
- data/gem_hadar.gemspec +3 -3
- data/lib/gem_hadar/changelog_generator.rb +60 -14
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar/version_spec.rb +56 -5
- data/lib/gem_hadar/warn.rb +18 -1
- data/lib/gem_hadar.rb +108 -56
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b073276ec181a5e9a9b2683fe8da14ac53c41f9234c643920883e575d7bc843
|
|
4
|
+
data.tar.gz: 805eb33b1fcbd4adc8b2c14dfc56a8d2c38564331d7534ebf5220355f8388920
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ca31b3c96e97f75ac16187337814ac43cc876c873342a0fb78daf4eaaecdfb3c1e56fd0ea3dc55ba657798e1b88e58a2084555b5e962891713b32397d9e4c9b
|
|
7
|
+
data.tar.gz: 97013a6905db1762f5f0c19fdfa329e1db0311f0d5044f6a0810a5ac89cf5e6133667c84af098c2c3dc9917eeb8876d55d4b5500f03d8d0f53c4cc5b8902fd79
|
data/gem_hadar.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: gem_hadar 2.
|
|
2
|
+
# stub: gem_hadar 2.13.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "gem_hadar".freeze
|
|
6
|
-
s.version = "2.
|
|
6
|
+
s.version = "2.13.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
|
|
24
24
|
s.specification_version = 4
|
|
25
25
|
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.13".freeze])
|
|
27
27
|
s.add_development_dependency(%q<all_images>.freeze, [">= 0".freeze])
|
|
28
28
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.13".freeze])
|
|
29
29
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
|
@@ -47,18 +47,18 @@ class GemHadar
|
|
|
47
47
|
# @return [ String ] a minimal changelog entry with just date and version
|
|
48
48
|
# when no changes are found
|
|
49
49
|
def generate(from, to = 'HEAD')
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
from = GemHadar::VersionSpec[from]
|
|
51
|
+
to = GemHadar::VersionSpec[to]
|
|
52
52
|
|
|
53
|
-
range = "#{
|
|
53
|
+
range = "#{from.tag}..#{to.tag}"
|
|
54
54
|
|
|
55
55
|
log = `git log #{range}`
|
|
56
56
|
$?.success? or raise "Failed to get git log for range #{range}"
|
|
57
57
|
|
|
58
|
-
date = `git log -n1 --pretty='format:%cd' --date=short #{
|
|
58
|
+
date = `git log -n1 --pretty='format:%cd' --date=short #{to.tag.inspect}`.chomp
|
|
59
59
|
|
|
60
60
|
if log.strip.empty?
|
|
61
|
-
return "\n## #{date} #{
|
|
61
|
+
return "\n## #{date} #{to.without_prefix.to_s}\n"
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
system = xdg_config('gem_hadar', 'changelog_system_prompt.txt', default_changelog_system_prompt)
|
|
@@ -69,7 +69,7 @@ class GemHadar
|
|
|
69
69
|
|
|
70
70
|
changes = response.gsub(/\t/, ' ')
|
|
71
71
|
|
|
72
|
-
return "\n## #{date} #{
|
|
72
|
+
return "\n## #{date} #{to.tag}\n\n#{changes}\n"
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# The generate_range method creates a changelog for a specific version
|
|
@@ -87,8 +87,8 @@ class GemHadar
|
|
|
87
87
|
# @param to [ String ] the ending version or commit reference for the
|
|
88
88
|
# range, defaults to 'HEAD'
|
|
89
89
|
def generate_range(output, from, to)
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
from = GemHadar::VersionSpec[from]
|
|
91
|
+
to = GemHadar::VersionSpec[to]
|
|
92
92
|
|
|
93
93
|
versions = read_versions
|
|
94
94
|
|
|
@@ -97,7 +97,7 @@ class GemHadar
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
versions = versions.select do |v|
|
|
100
|
-
v
|
|
100
|
+
v >= from && v <= to
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
changelog = generate_changelog(versions)
|
|
@@ -134,7 +134,7 @@ class GemHadar
|
|
|
134
134
|
|
|
135
135
|
changelog = generate_changelog(versions, changelog:)
|
|
136
136
|
|
|
137
|
-
changelog
|
|
137
|
+
changelog.unshift "# Changes\n"
|
|
138
138
|
|
|
139
139
|
output << changelog.join("")
|
|
140
140
|
end
|
|
@@ -151,11 +151,11 @@ class GemHadar
|
|
|
151
151
|
# @param filename [ String ] the path to the changelog file to which
|
|
152
152
|
# entries will be added
|
|
153
153
|
def add_to_file(filename)
|
|
154
|
-
highest_version =
|
|
154
|
+
highest_version = find_highest_version(filename)
|
|
155
155
|
|
|
156
156
|
if highest_version
|
|
157
157
|
versions = read_versions
|
|
158
|
-
versions = versions.drop_while { |t| t
|
|
158
|
+
versions = versions.drop_while { |t| t < highest_version }
|
|
159
159
|
else
|
|
160
160
|
raise ArgumentError, "Could not find highest version in #{filename.inspect}"
|
|
161
161
|
end
|
|
@@ -167,8 +167,54 @@ class GemHadar
|
|
|
167
167
|
inject_into_filename(filename, changelog)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
# The changelog_exist? method checks whether a changelog file exists in the
|
|
171
|
+
# project.
|
|
172
|
+
#
|
|
173
|
+
# This method verifies the presence of a changelog file by checking if the
|
|
174
|
+
# file path determined by changelog_filename exists in the filesystem.
|
|
175
|
+
#
|
|
176
|
+
# @return [ TrueClass, FalseClass ] true if the changelog file exists,
|
|
177
|
+
# false otherwise
|
|
178
|
+
def changelog_exist?
|
|
179
|
+
changelog_filename.exist?
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# The changelog_version_added? method checks whether a specific version has
|
|
183
|
+
# already been added to the changelog file.
|
|
184
|
+
#
|
|
185
|
+
# This method verifies if a given version is present in the changelog file
|
|
186
|
+
# by examining each line for a match with the version tag.
|
|
187
|
+
#
|
|
188
|
+
# @param version [ String ] the version to check for in the changelog
|
|
189
|
+
#
|
|
190
|
+
# @return [ TrueClass, FalseClass ] true if the version is found in the
|
|
191
|
+
# changelog, false otherwise
|
|
192
|
+
#
|
|
193
|
+
# @raise [ ArgumentError ] if the changelog file does not exist
|
|
194
|
+
def changelog_version_added?(version)
|
|
195
|
+
version = GemHadar::VersionSpec[version]
|
|
196
|
+
changelog_exist? or
|
|
197
|
+
raise ArgumentError, "Changelog #{changelog_filename.to_s} doesn't exist!"
|
|
198
|
+
File.new(changelog_filename).any? do |line|
|
|
199
|
+
line =~ /#{version.tag}/ and return true
|
|
200
|
+
end
|
|
201
|
+
false
|
|
202
|
+
end
|
|
203
|
+
|
|
170
204
|
private
|
|
171
205
|
|
|
206
|
+
# The changelog_filename method returns the Pathname object for the
|
|
207
|
+
# changelog file path.
|
|
208
|
+
#
|
|
209
|
+
# This method accesses the changelog_filename attribute from the associated
|
|
210
|
+
# GemHadar instance and wraps it in a Pathname object for convenient file
|
|
211
|
+
# path manipulation.
|
|
212
|
+
#
|
|
213
|
+
# @return [ Pathname ] the Pathname object representing the changelog file path
|
|
214
|
+
def changelog_filename
|
|
215
|
+
Pathname.new(@gem_hadar.changelog_filename)
|
|
216
|
+
end
|
|
217
|
+
|
|
172
218
|
# The ollama_generate method delegates AI generation requests to the
|
|
173
219
|
# associated GemHadar instance.
|
|
174
220
|
#
|
|
@@ -264,7 +310,7 @@ class GemHadar
|
|
|
264
310
|
end
|
|
265
311
|
end
|
|
266
312
|
|
|
267
|
-
# The
|
|
313
|
+
# The find_highest_version method extracts version specifications from
|
|
268
314
|
# a changelog file and returns the highest version found
|
|
269
315
|
#
|
|
270
316
|
# This method reads through the specified file line by line, scanning for
|
|
@@ -277,7 +323,7 @@ class GemHadar
|
|
|
277
323
|
#
|
|
278
324
|
# @return [ GemHadar::VersionSpec, nil ] the highest version specification
|
|
279
325
|
# found in the file, or nil if no versions are found
|
|
280
|
-
def
|
|
326
|
+
def find_highest_version(filename)
|
|
281
327
|
File.open(filename, ?r) do |input|
|
|
282
328
|
specs = []
|
|
283
329
|
input.each do |line|
|
data/lib/gem_hadar/version.rb
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
# representation.
|
|
8
8
|
#
|
|
9
9
|
# @example Creating a version specification
|
|
10
|
-
#
|
|
10
|
+
# version = GemHadar::VersionSpec['1.2.3']
|
|
11
11
|
#
|
|
12
12
|
# @example Checking if a version is a HEAD reference
|
|
13
|
-
#
|
|
14
|
-
#
|
|
13
|
+
# version = GemHadar::VersionSpec['HEAD']
|
|
14
|
+
# version.head? # => true
|
|
15
15
|
#
|
|
16
16
|
# @example Getting the version tag with appropriate prefixing
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# version = GemHadar::VersionSpec['1.2.3']
|
|
18
|
+
# version.tag # => 'v1.2.3'
|
|
19
19
|
#
|
|
20
20
|
# @example Comparing versions
|
|
21
21
|
# version1 = GemHadar::VersionSpec['1.2.3']
|
|
@@ -141,4 +141,55 @@ class GemHadar::VersionSpec
|
|
|
141
141
|
def with_prefix
|
|
142
142
|
to_s.sub(/\A(?!v)/, 'v')
|
|
143
143
|
end
|
|
144
|
+
|
|
145
|
+
# The <=> method compares this version specification with another object.
|
|
146
|
+
#
|
|
147
|
+
# This method implements the comparison operator for VersionSpec objects,
|
|
148
|
+
# allowing them to be sorted and compared using standard Ruby comparison
|
|
149
|
+
# operators.
|
|
150
|
+
#
|
|
151
|
+
# @param other [ Object ] the object to compare against
|
|
152
|
+
#
|
|
153
|
+
# @return [ Integer ] -1 if this version is less than the other, 0 if they
|
|
154
|
+
# are equal, 1 if this version is greater than the other
|
|
155
|
+
#
|
|
156
|
+
# @raise [ TypeError ] if the other object is not a VersionSpec instance
|
|
157
|
+
# @raise [ TypeError ] if the other object has no valid version to compare against
|
|
158
|
+
def <=>(other)
|
|
159
|
+
other.is_a?(self.class) or raise TypeError, "other needs to be a #{self.class}"
|
|
160
|
+
other.version or raise TypeError, "cannot compare to #{other.inspect}"
|
|
161
|
+
version <=> other.version
|
|
162
|
+
end
|
|
163
|
+
include Comparable
|
|
164
|
+
|
|
165
|
+
# The eql? method checks for equality between this version specification and
|
|
166
|
+
# another object.
|
|
167
|
+
#
|
|
168
|
+
# This method determines if the current VersionSpec instance is equal to another
|
|
169
|
+
# object by first checking if the other object is of the same class. If so, it
|
|
170
|
+
# compares either both objects represent HEAD references or their underlying
|
|
171
|
+
# version objects for equality.
|
|
172
|
+
#
|
|
173
|
+
# @param other [ Object ] the object to compare against
|
|
174
|
+
#
|
|
175
|
+
# @return [ TrueClass, FalseClass ] true if the objects are equal, false otherwise
|
|
176
|
+
def eql?(other)
|
|
177
|
+
other.is_a?(self.class) && (head? && other.head? || version == other.version)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# The hash method computes a hash value for the version specification.
|
|
181
|
+
#
|
|
182
|
+
# This method returns a hash code that represents the version specification.
|
|
183
|
+
# If the version specification has a valid version object, it returns the
|
|
184
|
+
# hash of that version object. Otherwise, it returns the hash of the string
|
|
185
|
+
# representation of the version specification.
|
|
186
|
+
#
|
|
187
|
+
# @return [ Integer ] the hash value of the version specification
|
|
188
|
+
def hash
|
|
189
|
+
if version?
|
|
190
|
+
version.hash
|
|
191
|
+
else
|
|
192
|
+
to_s.hash
|
|
193
|
+
end
|
|
194
|
+
end
|
|
144
195
|
end
|
data/lib/gem_hadar/warn.rb
CHANGED
|
@@ -29,7 +29,7 @@ class GemHadar
|
|
|
29
29
|
# @param msgs [ Array<String> ] the array of message strings to display as warnings
|
|
30
30
|
def warn(*msgs)
|
|
31
31
|
msgs.map! do |a|
|
|
32
|
-
a.respond_to?(:to_str) ? color(
|
|
32
|
+
a.respond_to?(:to_str) ? color(220) { a.to_str } : a
|
|
33
33
|
end
|
|
34
34
|
super(*msgs, uplevel: 1)
|
|
35
35
|
end
|
|
@@ -49,5 +49,22 @@ class GemHadar
|
|
|
49
49
|
end
|
|
50
50
|
super(*msgs)
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
# The abort method formats and displays failure messages using red colored
|
|
54
|
+
# output.
|
|
55
|
+
#
|
|
56
|
+
# This method takes an array of message objects, applies red color formatting
|
|
57
|
+
# to string representations of the messages, and then passes them to the
|
|
58
|
+
# superclass's abort method for display. The uplevel: 1 option ensures that
|
|
59
|
+
# the failure message originates from the caller's context rather than from
|
|
60
|
+
# within this method itself.
|
|
61
|
+
#
|
|
62
|
+
# @param msgs [ Array<Object> ] the array of message objects to display as failures
|
|
63
|
+
def abort(*msgs)
|
|
64
|
+
msgs.map! do |a|
|
|
65
|
+
a.respond_to?(:to_str) ? color(208) { a.to_str } : a
|
|
66
|
+
end
|
|
67
|
+
super(*msgs)
|
|
68
|
+
end
|
|
52
69
|
end
|
|
53
70
|
end
|
data/lib/gem_hadar.rb
CHANGED
|
@@ -598,6 +598,17 @@ class GemHadar
|
|
|
598
598
|
@rvm
|
|
599
599
|
end
|
|
600
600
|
|
|
601
|
+
# The changelog_filename attribute accessor for configuring the gem's
|
|
602
|
+
# changelog file name.
|
|
603
|
+
#
|
|
604
|
+
# This method sets up a DSL accessor for the changelog_filename attribute,
|
|
605
|
+
# which specifies the name of the changelog file to be used in the project.
|
|
606
|
+
# It provides a way to define a custom changelog filename that will be used
|
|
607
|
+
# during documentation generation and version management tasks.
|
|
608
|
+
#
|
|
609
|
+
# @return [ String, nil ] the name of the changelog file or nil if disabled.
|
|
610
|
+
dsl_accessor :changelog_filename
|
|
611
|
+
|
|
601
612
|
# The default_task_dependencies method manages the list of dependencies for
|
|
602
613
|
# the default Rake task.
|
|
603
614
|
#
|
|
@@ -838,7 +849,9 @@ class GemHadar
|
|
|
838
849
|
#
|
|
839
850
|
# @return [ String ] the git log output in patch format showing changes between the two versions
|
|
840
851
|
def version_log_diff(to_version: 'HEAD', from_version: nil)
|
|
841
|
-
|
|
852
|
+
to_version = GemHadar::VersionSpec[to_version]
|
|
853
|
+
from_version = from_version.full? { GemHadar::VersionSpec[from_version] }
|
|
854
|
+
if to_version.head?
|
|
842
855
|
if from_version.blank?
|
|
843
856
|
from_version = versions.last
|
|
844
857
|
else
|
|
@@ -846,7 +859,7 @@ class GemHadar
|
|
|
846
859
|
fail "Could not find #{from_version.inspect}."
|
|
847
860
|
end
|
|
848
861
|
end
|
|
849
|
-
`git log -p #{
|
|
862
|
+
`git log -p #{from_version.tag}..HEAD`
|
|
850
863
|
else
|
|
851
864
|
unless versions.find { |v| v == to_version }
|
|
852
865
|
fail "Could not find #{to_version.inspect}."
|
|
@@ -858,14 +871,14 @@ class GemHadar
|
|
|
858
871
|
end
|
|
859
872
|
end
|
|
860
873
|
unless from_version
|
|
861
|
-
return `git log -p #{
|
|
874
|
+
return `git log -p #{to_version.tag}`
|
|
862
875
|
end
|
|
863
876
|
else
|
|
864
877
|
unless versions.find { |v| v == from_version }
|
|
865
878
|
fail "Could not find #{from_version.inspect}."
|
|
866
879
|
end
|
|
867
880
|
end
|
|
868
|
-
`git log -p #{
|
|
881
|
+
`git log -p #{from_version.tag}..#{to_version.tag}`
|
|
869
882
|
end
|
|
870
883
|
end
|
|
871
884
|
|
|
@@ -911,8 +924,7 @@ class GemHadar
|
|
|
911
924
|
task :update do
|
|
912
925
|
answer = ask?("Which gem_hadar version? ", /^((?:\d+.){2}(?:\d+))$/)
|
|
913
926
|
unless answer
|
|
914
|
-
|
|
915
|
-
exit 1
|
|
927
|
+
abort "Invalid version specification!"
|
|
916
928
|
end
|
|
917
929
|
gem_hadar_version = answer[0]
|
|
918
930
|
filename = "#{name}.gemspec"
|
|
@@ -1097,6 +1109,37 @@ class GemHadar
|
|
|
1097
1109
|
end
|
|
1098
1110
|
end
|
|
1099
1111
|
|
|
1112
|
+
# The version_tag_local method retrieves the Git revision hash for the current version tag
|
|
1113
|
+
#
|
|
1114
|
+
# This method executes a Git command to obtain the full revision hash (commit SHA) associated
|
|
1115
|
+
# with the current gem version tag. It constructs the tag name using the GemHadar::VersionSpec
|
|
1116
|
+
# class and then uses Git's rev-parse command to resolve the tag to its corresponding commit.
|
|
1117
|
+
#
|
|
1118
|
+
# @return [ String ] the Git revision hash for the current version tag
|
|
1119
|
+
# @return [ String ] an empty string if the Git command fails
|
|
1120
|
+
# @return [ String ] the output of the Git rev-parse command as a string
|
|
1121
|
+
def version_tag_local
|
|
1122
|
+
`git show-ref #{GemHadar::VersionSpec[version].tag.inspect}`.
|
|
1123
|
+
chomp.sub(/\s.*/, '').full?
|
|
1124
|
+
end
|
|
1125
|
+
memoize method: :version_tag_local
|
|
1126
|
+
|
|
1127
|
+
# The version_tag_remote method retrieves the Git revision hash for the remote version tag
|
|
1128
|
+
#
|
|
1129
|
+
# This method executes a Git command to obtain the full revision hash (commit SHA) associated
|
|
1130
|
+
# with the current gem version tag on the remote repository. It constructs the tag name using
|
|
1131
|
+
# the GemHadar::VersionSpec class and then uses Git's ls-remote command to resolve the tag
|
|
1132
|
+
# to its corresponding commit on the specified remote.
|
|
1133
|
+
#
|
|
1134
|
+
# @return [ String ] the Git revision hash for the remote version tag
|
|
1135
|
+
# @return [ String ] an empty string if the Git command fails or no remote tag is found
|
|
1136
|
+
# @return [ String ] the output of the Git ls-remote command as a string
|
|
1137
|
+
def version_tag_remote
|
|
1138
|
+
`git ls-remote --tags #{git_remote} #{GemHadar::VersionSpec[version].tag.inspect}`.
|
|
1139
|
+
chomp.sub(/\s.*/, '').full?
|
|
1140
|
+
end
|
|
1141
|
+
memoize method: :version_tag_remote
|
|
1142
|
+
|
|
1100
1143
|
# The version_tag_task method defines a Rake task that creates a Git tag for
|
|
1101
1144
|
# the current version.
|
|
1102
1145
|
#
|
|
@@ -1108,24 +1151,29 @@ class GemHadar
|
|
|
1108
1151
|
# overwrite it forcefully.
|
|
1109
1152
|
def version_tag_task
|
|
1110
1153
|
namespace :version do
|
|
1154
|
+
namespace :tag do
|
|
1155
|
+
desc "show local tag revision"
|
|
1156
|
+
task :local do
|
|
1157
|
+
system 'git fetch --tags'
|
|
1158
|
+
puts version_tag_local
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
desc "show remote tag revision"
|
|
1162
|
+
task :remote do
|
|
1163
|
+
puts version_tag_remote
|
|
1164
|
+
end
|
|
1165
|
+
end
|
|
1166
|
+
|
|
1111
1167
|
desc "Tag this commit as version #{version}"
|
|
1112
|
-
task :tag do
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
else
|
|
1120
|
-
if ask?("Different version tag #{version} already exists. Overwrite with "\
|
|
1121
|
-
"force? (yes/NO) ", /\Ayes\z/i)
|
|
1122
|
-
force = true
|
|
1123
|
-
retry
|
|
1124
|
-
else
|
|
1125
|
-
exit 1
|
|
1126
|
-
end
|
|
1127
|
-
end
|
|
1168
|
+
task :tag => :modified do
|
|
1169
|
+
version_spec = GemHadar::VersionSpec[version]
|
|
1170
|
+
if sha = version_tag_remote
|
|
1171
|
+
abort <<~EOT.chomp
|
|
1172
|
+
Remote version tag #{version_spec.tag.inspect} already exists and points to #{sha.inspect}!"
|
|
1173
|
+
Call version:bump first to create a new version before release.
|
|
1174
|
+
EOT
|
|
1128
1175
|
end
|
|
1176
|
+
sh "git tag -a -m 'Version #{version_spec.untag}' -f #{version_spec.tag.inspect}"
|
|
1129
1177
|
end
|
|
1130
1178
|
end
|
|
1131
1179
|
end
|
|
@@ -1256,8 +1304,7 @@ class GemHadar
|
|
|
1256
1304
|
exit 1
|
|
1257
1305
|
end
|
|
1258
1306
|
else
|
|
1259
|
-
|
|
1260
|
-
exit 1
|
|
1307
|
+
abort "Cannot push gem to rubygems: #{path.inspect} doesn't exist."
|
|
1261
1308
|
end
|
|
1262
1309
|
end
|
|
1263
1310
|
end
|
|
@@ -1324,7 +1371,7 @@ class GemHadar
|
|
|
1324
1371
|
end
|
|
1325
1372
|
if %r(\A/*(?<owner>[^/]+)/(?<repo>[^/.]+)) =~ github_remote_url&.path
|
|
1326
1373
|
rc = GitHub::ReleaseCreator.new(owner:, repo:, token: github_api_token)
|
|
1327
|
-
tag_name =
|
|
1374
|
+
tag_name = GemHadar::VersionSpec[version].tag
|
|
1328
1375
|
target_commitish = `git show -s --format=%H #{tag_name.inspect}^{commit}`.chomp
|
|
1329
1376
|
body = edit_temp_file(create_git_release_body)
|
|
1330
1377
|
if body.present?
|
|
@@ -1344,6 +1391,23 @@ class GemHadar
|
|
|
1344
1391
|
end
|
|
1345
1392
|
end
|
|
1346
1393
|
|
|
1394
|
+
# The modified_task method defines a Rake task that checks for uncommitted
|
|
1395
|
+
# changes in the Git repository
|
|
1396
|
+
#
|
|
1397
|
+
# This method creates a Rake task named :modified that runs a Git status
|
|
1398
|
+
# command to identify any modified files that are not yet committed. If any
|
|
1399
|
+
# changed files are found, it aborts the task execution and displays a
|
|
1400
|
+
# message
|
|
1401
|
+
# listing all the uncommitted files
|
|
1402
|
+
def modified_task
|
|
1403
|
+
task :modified do
|
|
1404
|
+
changed_files = `git status --porcelain`.gsub(/^\s*\S\s+/, '').lines
|
|
1405
|
+
unless changed_files.empty?
|
|
1406
|
+
abort "There are still modified files:\n#{changed_files * ''}"
|
|
1407
|
+
end
|
|
1408
|
+
end
|
|
1409
|
+
end
|
|
1410
|
+
|
|
1347
1411
|
# The push_task_dependencies method manages the list of dependencies for the push task.
|
|
1348
1412
|
#
|
|
1349
1413
|
# This method sets up a DSL accessor for the push_task_dependencies attribute,
|
|
@@ -1371,13 +1435,7 @@ class GemHadar
|
|
|
1371
1435
|
gem_push_task
|
|
1372
1436
|
git_remotes_task
|
|
1373
1437
|
github_release_task
|
|
1374
|
-
|
|
1375
|
-
changed_files = `git status --porcelain`.gsub(/^\s*\S\s+/, '').lines
|
|
1376
|
-
unless changed_files.empty?
|
|
1377
|
-
warn "There are still modified files:\n#{changed_files * ''}"
|
|
1378
|
-
exit 1
|
|
1379
|
-
end
|
|
1380
|
-
end
|
|
1438
|
+
modified_task
|
|
1381
1439
|
desc "Push all changes for version #{version} into the internets."
|
|
1382
1440
|
task :push => push_task_dependencies
|
|
1383
1441
|
end
|
|
@@ -1391,7 +1449,7 @@ class GemHadar
|
|
|
1391
1449
|
# with a single command.
|
|
1392
1450
|
def release_task
|
|
1393
1451
|
desc "Release the new version #{version} for the gem #{name}."
|
|
1394
|
-
task :release => :push
|
|
1452
|
+
task :release => [ :'changes:added', :push ]
|
|
1395
1453
|
end
|
|
1396
1454
|
|
|
1397
1455
|
# The compile_task method sets up a Rake task to compile project extensions.
|
|
@@ -1604,6 +1662,7 @@ class GemHadar
|
|
|
1604
1662
|
# - :changes:range - Show changes for a specific Git range
|
|
1605
1663
|
# - :changes:full - Generate complete changelog from first tag
|
|
1606
1664
|
# - :changes:add - Append to existing changelog file
|
|
1665
|
+
# - :changes:added - Check if the current version was added to changelog file
|
|
1607
1666
|
def changes_task
|
|
1608
1667
|
namespace :changes do
|
|
1609
1668
|
desc 'Show changes since last version tag'
|
|
@@ -1668,9 +1727,18 @@ class GemHadar
|
|
|
1668
1727
|
|
|
1669
1728
|
desc 'Append new entries to existing changelog file'
|
|
1670
1729
|
task :add do
|
|
1671
|
-
filename = ARGV[1]
|
|
1730
|
+
filename = ARGV[1] || changelog_filename
|
|
1731
|
+
filename or raise 'Need file to add to'
|
|
1672
1732
|
GemHadar::ChangelogGenerator.new(self).add_to_file(filename)
|
|
1673
1733
|
end
|
|
1734
|
+
|
|
1735
|
+
desc 'Check if current version was added to the changelog'
|
|
1736
|
+
task :added do
|
|
1737
|
+
changelog_filename or next
|
|
1738
|
+
GemHadar::ChangelogGenerator.new(self).changelog_version_added?(version) and next
|
|
1739
|
+
abort "Version #{GemHadar::VersionSpec[version].untag} has not been "\
|
|
1740
|
+
"documented in changelog #{changelog_filename.inspect} file."
|
|
1741
|
+
end
|
|
1674
1742
|
end
|
|
1675
1743
|
|
|
1676
1744
|
# Main changes task that shows help when called directly
|
|
@@ -1683,6 +1751,7 @@ class GemHadar
|
|
|
1683
1751
|
rake changes:range <range> Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)
|
|
1684
1752
|
rake changes:full [file] Generate complete changelog from first tag
|
|
1685
1753
|
rake changes:add <file> Append new entries to existing changelog file
|
|
1754
|
+
rake changes:added Check if current version was added to changelog
|
|
1686
1755
|
|
|
1687
1756
|
Examples:
|
|
1688
1757
|
rake changes:pending
|
|
@@ -1691,6 +1760,7 @@ class GemHadar
|
|
|
1691
1760
|
rake changes:full
|
|
1692
1761
|
rake changes:full CHANGES.md
|
|
1693
1762
|
rake changes:add CHANGES.md
|
|
1763
|
+
rake changes:added
|
|
1694
1764
|
EOT
|
|
1695
1765
|
end
|
|
1696
1766
|
end
|
|
@@ -1799,9 +1869,9 @@ class GemHadar
|
|
|
1799
1869
|
# - The start version (e.g., '1.2.3') from which changes are compared.
|
|
1800
1870
|
# - The end version (e.g., '1.2.4' or 'HEAD') up to which changes are compared.
|
|
1801
1871
|
def determine_version_range
|
|
1802
|
-
version_tags = versions.map {
|
|
1803
|
-
found_version_tag = version_tags.index(
|
|
1804
|
-
found_version_tag.nil? and fail "cannot find version tag #{
|
|
1872
|
+
version_tags = versions.map { GemHadar::VersionSpec[_1].tag } + %w[ HEAD ]
|
|
1873
|
+
found_version_tag = version_tags.index(GemHadar::VersionSpec[version].tag)
|
|
1874
|
+
found_version_tag.nil? and fail "cannot find version tag #{GemHadar::VersionSpec[version].tag}"
|
|
1805
1875
|
start_version, end_version = version_tags[found_version_tag, 2]
|
|
1806
1876
|
return start_version, end_version
|
|
1807
1877
|
end
|
|
@@ -1886,7 +1956,7 @@ class GemHadar
|
|
|
1886
1956
|
def gemspec
|
|
1887
1957
|
Gem::Specification.new do |s|
|
|
1888
1958
|
s.name = name
|
|
1889
|
-
s.version = ::Gem::Version.new(
|
|
1959
|
+
s.version = ::Gem::Version.new(GemHadar::VersionSpec[version].untag)
|
|
1890
1960
|
s.author = author
|
|
1891
1961
|
s.email = email
|
|
1892
1962
|
s.homepage = assert_valid_link(:homepage, homepage)
|
|
@@ -1975,24 +2045,6 @@ class GemHadar
|
|
|
1975
2045
|
}.sort_by(&:version)
|
|
1976
2046
|
end
|
|
1977
2047
|
|
|
1978
|
-
# The version_tag method prepends a 'v' prefix to the given version
|
|
1979
|
-
# string, unless it's HEAD.
|
|
1980
|
-
#
|
|
1981
|
-
# @param version [String] the version string to modify
|
|
1982
|
-
# @return [String] the modified version string with a 'v' prefix
|
|
1983
|
-
def version_tag(version)
|
|
1984
|
-
GemHadar::VersionSpec[version].tag
|
|
1985
|
-
end
|
|
1986
|
-
|
|
1987
|
-
# The version_untag method removes the 'v' prefix from a version tag string.
|
|
1988
|
-
#
|
|
1989
|
-
# @param version_tag [ String ] the version tag string that may start with 'v'
|
|
1990
|
-
#
|
|
1991
|
-
# @return [ String ] the version string with the 'v' prefix removed
|
|
1992
|
-
def version_untag(version_tag)
|
|
1993
|
-
GemHadar::VersionSpec[version].untag
|
|
1994
|
-
end
|
|
1995
|
-
|
|
1996
2048
|
# The github_remote_url method retrieves and parses the GitHub remote URL
|
|
1997
2049
|
# from the local Git configuration.
|
|
1998
2050
|
#
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_hadar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.
|
|
18
|
+
version: '2.13'
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.
|
|
25
|
+
version: '2.13'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|