gem_hadar 2.11.0 → 2.12.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 +13 -13
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar/version_spec.rb +56 -5
- data/lib/gem_hadar.rb +12 -28
- 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: 695a7ff7bd975c62a492a7201233a82758d5f1ba55c2da575f4efc90d477b3d6
|
|
4
|
+
data.tar.gz: 24338fcf746d7af9bbe140283ef9d90257f04fb10c3e36f8bb2bcf4a6beee140
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d50e942241bb49b5aacacaf84760bd8123e3bef6b4c8addb7e988d16c71434d8506ac28ba382a99193483bd2a37c53ef56f4d091a9c1c655715276a038f1b8a8
|
|
7
|
+
data.tar.gz: a25eda3b38ebc77b8b5eb2fa15532b7e5f6f83da7f257accd2ec4e2e12eee835f9b087523b6b8c6a7e142946cf81f7da0320dc9e6a9badf90bf76486bf7f3452
|
data/gem_hadar.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: gem_hadar 2.
|
|
2
|
+
# stub: gem_hadar 2.12.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.12.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.12".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)
|
|
@@ -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
|
|
@@ -264,7 +264,7 @@ class GemHadar
|
|
|
264
264
|
end
|
|
265
265
|
end
|
|
266
266
|
|
|
267
|
-
# The
|
|
267
|
+
# The find_highest_version method extracts version specifications from
|
|
268
268
|
# a changelog file and returns the highest version found
|
|
269
269
|
#
|
|
270
270
|
# This method reads through the specified file line by line, scanning for
|
|
@@ -277,7 +277,7 @@ class GemHadar
|
|
|
277
277
|
#
|
|
278
278
|
# @return [ GemHadar::VersionSpec, nil ] the highest version specification
|
|
279
279
|
# found in the file, or nil if no versions are found
|
|
280
|
-
def
|
|
280
|
+
def find_highest_version(filename)
|
|
281
281
|
File.open(filename, ?r) do |input|
|
|
282
282
|
specs = []
|
|
283
283
|
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.rb
CHANGED
|
@@ -838,7 +838,9 @@ class GemHadar
|
|
|
838
838
|
#
|
|
839
839
|
# @return [ String ] the git log output in patch format showing changes between the two versions
|
|
840
840
|
def version_log_diff(to_version: 'HEAD', from_version: nil)
|
|
841
|
-
|
|
841
|
+
to_version = GemHadar::VersionSpec[to_version]
|
|
842
|
+
from_version = from_version.full? { GemHadar::VersionSpec[from_version] }
|
|
843
|
+
if to_version.head?
|
|
842
844
|
if from_version.blank?
|
|
843
845
|
from_version = versions.last
|
|
844
846
|
else
|
|
@@ -846,7 +848,7 @@ class GemHadar
|
|
|
846
848
|
fail "Could not find #{from_version.inspect}."
|
|
847
849
|
end
|
|
848
850
|
end
|
|
849
|
-
`git log -p #{
|
|
851
|
+
`git log -p #{from_version.tag}..HEAD`
|
|
850
852
|
else
|
|
851
853
|
unless versions.find { |v| v == to_version }
|
|
852
854
|
fail "Could not find #{to_version.inspect}."
|
|
@@ -858,14 +860,14 @@ class GemHadar
|
|
|
858
860
|
end
|
|
859
861
|
end
|
|
860
862
|
unless from_version
|
|
861
|
-
return `git log -p #{
|
|
863
|
+
return `git log -p #{to_version.tag}`
|
|
862
864
|
end
|
|
863
865
|
else
|
|
864
866
|
unless versions.find { |v| v == from_version }
|
|
865
867
|
fail "Could not find #{from_version.inspect}."
|
|
866
868
|
end
|
|
867
869
|
end
|
|
868
|
-
`git log -p #{
|
|
870
|
+
`git log -p #{from_version.tag}..#{to_version.tag}`
|
|
869
871
|
end
|
|
870
872
|
end
|
|
871
873
|
|
|
@@ -1112,7 +1114,7 @@ class GemHadar
|
|
|
1112
1114
|
task :tag do
|
|
1113
1115
|
force = ENV['FORCE'].to_i == 1
|
|
1114
1116
|
begin
|
|
1115
|
-
sh "git tag -a -m 'Version #{version}' #{'-f' if force} #{
|
|
1117
|
+
sh "git tag -a -m 'Version #{version}' #{'-f' if force} #{GemHadar::VersionSpec[version].tag}"
|
|
1116
1118
|
rescue RuntimeError
|
|
1117
1119
|
if `git diff v#{version}..HEAD`.empty?
|
|
1118
1120
|
puts "Version #{version} is already tagged, but it's no different"
|
|
@@ -1324,7 +1326,7 @@ class GemHadar
|
|
|
1324
1326
|
end
|
|
1325
1327
|
if %r(\A/*(?<owner>[^/]+)/(?<repo>[^/.]+)) =~ github_remote_url&.path
|
|
1326
1328
|
rc = GitHub::ReleaseCreator.new(owner:, repo:, token: github_api_token)
|
|
1327
|
-
tag_name =
|
|
1329
|
+
tag_name = GemHadar::VersionSpec[version].tag
|
|
1328
1330
|
target_commitish = `git show -s --format=%H #{tag_name.inspect}^{commit}`.chomp
|
|
1329
1331
|
body = edit_temp_file(create_git_release_body)
|
|
1330
1332
|
if body.present?
|
|
@@ -1799,9 +1801,9 @@ class GemHadar
|
|
|
1799
1801
|
# - The start version (e.g., '1.2.3') from which changes are compared.
|
|
1800
1802
|
# - The end version (e.g., '1.2.4' or 'HEAD') up to which changes are compared.
|
|
1801
1803
|
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 #{
|
|
1804
|
+
version_tags = versions.map { GemHadar::VersionSpec[_1].tag } + %w[ HEAD ]
|
|
1805
|
+
found_version_tag = version_tags.index(GemHadar::VersionSpec[version].tag)
|
|
1806
|
+
found_version_tag.nil? and fail "cannot find version tag #{GemHadar::VersionSpec[version].tag}"
|
|
1805
1807
|
start_version, end_version = version_tags[found_version_tag, 2]
|
|
1806
1808
|
return start_version, end_version
|
|
1807
1809
|
end
|
|
@@ -1886,7 +1888,7 @@ class GemHadar
|
|
|
1886
1888
|
def gemspec
|
|
1887
1889
|
Gem::Specification.new do |s|
|
|
1888
1890
|
s.name = name
|
|
1889
|
-
s.version = ::Gem::Version.new(
|
|
1891
|
+
s.version = ::Gem::Version.new(GemHadar::VersionSpec[version].untag)
|
|
1890
1892
|
s.author = author
|
|
1891
1893
|
s.email = email
|
|
1892
1894
|
s.homepage = assert_valid_link(:homepage, homepage)
|
|
@@ -1975,24 +1977,6 @@ class GemHadar
|
|
|
1975
1977
|
}.sort_by(&:version)
|
|
1976
1978
|
end
|
|
1977
1979
|
|
|
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
1980
|
# The github_remote_url method retrieves and parses the GitHub remote URL
|
|
1997
1981
|
# from the local Git configuration.
|
|
1998
1982
|
#
|
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.12.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.12'
|
|
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.12'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|