kettle-gha-pins 0.3.7 → 0.3.8

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: e55947f165ea60fdf05e34f18bbd7af157e37c2e0da0c975a721ca6672da0b9f
4
- data.tar.gz: eaaa403c59388d699bc50d0108ff1211d6249933dfd0304a5cd896980a3b646f
3
+ metadata.gz: 0a1c43269ba88dfec876d3107fb7883511cbcec7456353a8e239d74071d0d94e
4
+ data.tar.gz: 7499e3b722b86736e91a8a1dfde9ea53ab4f261428e5ec6816a83db73f428ece
5
5
  SHA512:
6
- metadata.gz: 24b75d7754e3617cee6eb4178495de33b813e940b65b3a83c64201ad539edcaeb9038cec38b25bafe4f7f9a2510771e4c34d24282043b737b412066580627641
7
- data.tar.gz: afceb46d10b46e25d008a125d3d724f3aec05fc3f468aa388aa0cc899b1f5aae6b64c2271651c74b7fd22da364766740098ec037a385b490453c5cd3a082b06d
6
+ metadata.gz: d05a9abcb27812e5db10f60e44e3eb9b2e40cd9747476078a22008dab208a578ed816a93255093255ee86f24ccb5856f2ae1fda212659cd97f005d12a5b6bbfb
7
+ data.tar.gz: 06bf550cb1113a1acb1363307d6dc4faa902c8d283aae15ecdfffaba658b9391d09606cb8005bb6071a30031bcd72b3046aae3674f2b359789793b78c2e82f59
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,17 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.3.8] - 2026-08-05
34
+
35
+ - TAG: [v0.3.8][0.3.8t]
36
+ - COVERAGE: 98.34% -- 945/961 lines in 8 files
37
+ - BRANCH COVERAGE: 89.81% -- 388/432 branches in 8 files
38
+ - 25.71% documented
39
+
40
+ ### Fixed
41
+
42
+ - Refresh cached GitHub Action release data when a newer release tag is detected.
43
+
33
44
  ## [0.3.7] - 2026-08-05
34
45
 
35
46
  - TAG: [v0.3.7][0.3.7t]
@@ -260,7 +271,9 @@ Please file a bug if you notice a violation of semantic versioning.
260
271
  - kettle-jem-template-20260720-005 - Generated README Support & Community rows
261
272
  now include a RubyForum help badge.
262
273
 
263
- [Unreleased]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.7...HEAD
274
+ [Unreleased]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.8...HEAD
275
+ [0.3.8]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.7...v0.3.8
276
+ [0.3.8t]: https://github.com/kettle-dev/kettle-gha-pins/releases/tag/v0.3.8
264
277
  [0.3.7]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.6...v0.3.7
265
278
  [0.3.7t]: https://github.com/kettle-dev/kettle-gha-pins/releases/tag/v0.3.7
266
279
  [0.3.6]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.5...v0.3.6
data/README.md CHANGED
@@ -563,7 +563,7 @@ Thanks for RTFM. ☺️
563
563
  [📌gitmoji]: https://gitmoji.dev
564
564
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
565
565
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
566
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.941-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
566
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.961-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
567
567
  [🔐security]: https://github.com/kettle-dev/kettle-gha-pins/blob/main/SECURITY.md
568
568
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
569
569
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -115,7 +115,8 @@ module Kettle
115
115
  reason: reason,
116
116
  current_version: current_version,
117
117
  versions: available_versions,
118
- latest_outdated: latest_outdated
118
+ latest_outdated: latest_outdated,
119
+ current_sha: current_sha
119
120
  }
120
121
  end
121
122
 
@@ -154,7 +154,8 @@ module Kettle
154
154
  comment_update_version = VersionRubric.comment_update_version(
155
155
  comment_version,
156
156
  upgrade_plan[:current_version],
157
- known_versions: upgrade_plan.fetch(:versions, [])
157
+ known_versions: upgrade_plan.fetch(:versions, []),
158
+ resolved_sha: upgrade_plan[:current_sha]
158
159
  )
159
160
  if comment_update_version
160
161
  updates = {
@@ -38,9 +38,11 @@ module Kettle
38
38
  unless @refresh_cache
39
39
  cached = @persistent_cache&.versions_for_repo(repo_ref, fresh: true)
40
40
  if cached
41
- @last_versions_cache_hit = true
42
- @release_cache[repo_ref] = cached
43
- return cached
41
+ unless cache_requires_refresh?(repo_ref, cached)
42
+ @last_versions_cache_hit = true
43
+ @release_cache[repo_ref] = cached
44
+ return cached
45
+ end
44
46
  end
45
47
  stale = @persistent_cache&.versions_for_repo(repo_ref, fresh: false)
46
48
  end
@@ -62,13 +64,13 @@ module Kettle
62
64
  cached_versions(repo_ref, stale)
63
65
  end
64
66
 
65
- def commit_sha(repo_ref, ref)
67
+ def commit_sha(repo_ref, ref, refresh: false)
66
68
  return nil if repo_ref.to_s.empty? || ref.to_s.empty?
67
69
 
68
70
  cache_key = "commit:#{repo_ref}:#{ref}"
69
- return @commit_cache[cache_key] if @commit_cache.key?(cache_key)
71
+ return @commit_cache[cache_key] if @commit_cache.key?(cache_key) && !refresh
70
72
 
71
- unless @refresh_cache
73
+ unless @refresh_cache || refresh
72
74
  cached = @persistent_cache&.ref_sha(repo_ref, ref, fresh: true)
73
75
  if cached
74
76
  @commit_cache[cache_key] = cached
@@ -104,6 +106,26 @@ module Kettle
104
106
  versions
105
107
  end
106
108
 
109
+ # Release tags can be added or retargeted inside the cache TTL. Probe
110
+ # the latest release before trusting a cached inventory, and refresh
111
+ # only when that probe identifies a tag or target the cache lacks.
112
+ def cache_requires_refresh?(repo_ref, cached)
113
+ latest = request_json("/repos/#{repo_ref}/releases/latest")
114
+ return false unless latest.is_a?(Hash)
115
+
116
+ tag = latest["tag_name"].to_s
117
+ return false unless VersionRubric.parse(tag)
118
+
119
+ cached_entry = cached.find { |entry| entry[:tag].to_s == tag }
120
+ return true unless cached_entry
121
+
122
+ latest_sha = commit_sha(repo_ref, tag, refresh: true)
123
+ cached_sha = cached_entry[:sha].to_s
124
+ return !latest_sha.to_s.empty? if cached_sha.empty?
125
+
126
+ !latest_sha.to_s.empty? && latest_sha != cached_sha
127
+ end
128
+
107
129
  def build_release_versions(data, tag_shas)
108
130
  release_dates = {}
109
131
  release_tags = data.each_with_object([]) do |release, memo|
@@ -143,7 +165,7 @@ module Kettle
143
165
  when "commit"
144
166
  memo[tag] = sha
145
167
  when "tag"
146
- memo[tag] = nil
168
+ memo[tag] = annotated_tag_commit_sha(repo_ref, sha)
147
169
  end
148
170
  end
149
171
  end
@@ -6,7 +6,7 @@ module Kettle
6
6
  # Version namespace for this gem.
7
7
  module Version
8
8
  # Current gem version.
9
- VERSION = "0.3.7"
9
+ VERSION = "0.3.8"
10
10
  end
11
11
  # Current gem version exposed at the traditional constant location.
12
12
  VERSION = Version::VERSION # Traditional Constant Location
@@ -112,12 +112,17 @@ module Kettle
112
112
  # the comment even when both values parse to version objects).
113
113
  # 2. Normalize equivalent spellings (v2, v2.0, v2.0.0...) to the most
114
114
  # specific canonical form available for that SHA in known_versions.
115
- def comment_update_version(comment_version, resolved_version, known_versions: [])
115
+ def comment_update_version(comment_version, resolved_version, resolved_sha: nil, known_versions: [])
116
116
  comment = parse(comment_version)
117
117
  resolved = parse(resolved_version)
118
118
  return nil unless comment && resolved
119
119
 
120
- canonical = canonical_version_for(resolved_version, known_versions)
120
+ canonical = canonical_version_for(
121
+ resolved_version,
122
+ known_versions,
123
+ resolved_sha: resolved_sha,
124
+ comment_version: comment_version
125
+ )
121
126
  return nil if comment_version.to_s == canonical
122
127
 
123
128
  canonical
@@ -127,18 +132,40 @@ module Kettle
127
132
  versions.select { |entry| entry.fetch(:version_obj, nil) == version_obj }
128
133
  end
129
134
 
130
- # When multiple release spellings resolve to the same SHA, prefer the
131
- # most specific equivalent tag. If there is no known equivalent, fall
132
- # back to the plain resolved version string.
133
- def canonical_version_for(resolved_version, known_versions)
135
+ # Canonical spellings are version-specific and SHA-aware.
136
+ #
137
+ # - For SHA-tracked tags, prefer the most explicit spelling that resolves
138
+ # to the same SHA as the currently resolved target.
139
+ # - If the resolved SHA is known but the currently-commented spellings
140
+ # are tied to a different SHA, keep the in-file spelling when the
141
+ # semantic version is unchanged, so we don't rewrite between aliases that
142
+ # no longer represent the same object.
143
+ # - Otherwise fall back to the resolved version form.
144
+ def canonical_version_for(resolved_version, known_versions, resolved_sha: nil, comment_version: nil)
134
145
  resolved = parse(resolved_version)
135
146
  return resolved_version.to_s unless resolved
136
147
 
137
148
  equivalents = entries_for_semantic_version(known_versions, resolved)
149
+ if !resolved_sha.to_s.empty?
150
+ sha_matched_equivalents = equivalents.select do |entry|
151
+ entry.fetch(:sha).to_s == resolved_sha.to_s
152
+ end
153
+ equivalents = sha_matched_equivalents unless sha_matched_equivalents.empty?
154
+
155
+ if sha_matched_equivalents.empty? &&
156
+ comment_version &&
157
+ parse(comment_version) == resolved
158
+ return strip_leading_v(comment_version)
159
+ end
160
+ end
138
161
  preferred = equivalents.max_by { |entry| sort_key(entry) }
139
162
  preferred ? preferred[:version] : resolved.to_s
140
163
  end
141
164
 
165
+ def strip_leading_v(text)
166
+ text.to_s.sub(/\A[vV]/, "")
167
+ end
168
+
142
169
  def normalize_upgrade_level(level)
143
170
  normalized = level.to_s.downcase
144
171
  VALID_UPGRADE_LEVELS.include?(normalized) ? normalized : DEFAULT_UPGRADE_LEVEL
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kettle-gha-pins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -301,10 +301,10 @@ licenses:
301
301
  - MIT
302
302
  metadata:
303
303
  homepage_uri: https://github.com/kettle-dev/kettle-gha-pins
304
- source_code_uri: https://github.com/kettle-dev/kettle-gha-pins/tree/v0.3.7
305
- changelog_uri: https://github.com/kettle-dev/kettle-gha-pins/blob/v0.3.7/CHANGELOG.md
304
+ source_code_uri: https://github.com/kettle-dev/kettle-gha-pins/tree/v0.3.8
305
+ changelog_uri: https://github.com/kettle-dev/kettle-gha-pins/blob/v0.3.8/CHANGELOG.md
306
306
  bug_tracker_uri: https://github.com/kettle-dev/kettle-gha-pins/issues
307
- documentation_uri: https://www.rubydoc.info/gems/kettle-gha-pins/0.3.7
307
+ documentation_uri: https://www.rubydoc.info/gems/kettle-gha-pins/0.3.8
308
308
  funding_uri: https://github.com/sponsors/pboling
309
309
  wiki_uri: https://github.com/kettle-dev/kettle-gha-pins/wiki
310
310
  news_uri: https://www.railsbling.com/tags/kettle-gha-pins
metadata.gz.sig CHANGED
Binary file