kettle-gha-pins 0.3.6 → 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: b985aaa740f2f6f46ff9c0e71c7b51cc69cb23b2a1e8786258c46c34ee08be2e
4
- data.tar.gz: 5a9c0fe7c26efe095e2e138a15ab9233e513f3dfb514818642b8c148f623940f
3
+ metadata.gz: 0a1c43269ba88dfec876d3107fb7883511cbcec7456353a8e239d74071d0d94e
4
+ data.tar.gz: 7499e3b722b86736e91a8a1dfde9ea53ab4f261428e5ec6816a83db73f428ece
5
5
  SHA512:
6
- metadata.gz: a06b224317f385390101c1b69648cc3a87345a016376643b8b17bd398823534e692942c57a12c6036665231e2233e00c85ce2374aa4c46df8e79467572480761
7
- data.tar.gz: a62ad7ef161155e77688213c211d69a5b283a7825f0aed524f8c0ac1dfcda67c489b36310ac6f27b9c68c9127b018eff63658648a8eb68d8690141ff65662629
6
+ metadata.gz: d05a9abcb27812e5db10f60e44e3eb9b2e40cd9747476078a22008dab208a578ed816a93255093255ee86f24ccb5856f2ae1fda212659cd97f005d12a5b6bbfb
7
+ data.tar.gz: 06bf550cb1113a1acb1363307d6dc4faa902c8d283aae15ecdfffaba658b9391d09606cb8005bb6071a30031bcd72b3046aae3674f2b359789793b78c2e82f59
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,24 @@ 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
+
44
+ ## [0.3.7] - 2026-08-05
45
+
46
+ - TAG: [v0.3.7][0.3.7t]
47
+ - COVERAGE: 98.94% -- 931/941 lines in 8 files
48
+ - BRANCH COVERAGE: 90.87% -- 378/416 branches in 8 files
49
+ - 25.96% documented
50
+
33
51
  ## [0.3.6] - 2026-08-03
34
52
 
35
53
  - TAG: [v0.3.6][0.3.6t]
@@ -253,7 +271,11 @@ Please file a bug if you notice a violation of semantic versioning.
253
271
  - kettle-jem-template-20260720-005 - Generated README Support & Community rows
254
272
  now include a RubyForum help badge.
255
273
 
256
- [Unreleased]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.6...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
277
+ [0.3.7]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.6...v0.3.7
278
+ [0.3.7t]: https://github.com/kettle-dev/kettle-gha-pins/releases/tag/v0.3.7
257
279
  [0.3.6]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.5...v0.3.6
258
280
  [0.3.6t]: https://github.com/kettle-dev/kettle-gha-pins/releases/tag/v0.3.6
259
281
  [0.3.5]: https://github.com/kettle-dev/kettle-gha-pins/compare/v0.3.4...v0.3.5
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.945-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.6"
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
@@ -106,37 +106,64 @@ module Kettle
106
106
  end.max_by { |entry| sort_key(entry) }
107
107
  end
108
108
 
109
- def comment_update_version(comment_version, resolved_version, known_versions: [])
109
+ # The comment on `uses:` is a cached record that needs to do two things:
110
+ #
111
+ # 1. Track the currently resolved target (if the target changes, update
112
+ # the comment even when both values parse to version objects).
113
+ # 2. Normalize equivalent spellings (v2, v2.0, v2.0.0...) to the most
114
+ # specific canonical form available for that SHA in known_versions.
115
+ def comment_update_version(comment_version, resolved_version, resolved_sha: nil, known_versions: [])
110
116
  comment = parse(comment_version)
111
117
  resolved = parse(resolved_version)
112
118
  return nil unless comment && resolved
113
119
 
114
- resolved_entry = exact_entry_for_version(known_versions, resolved_version)
115
- comment_entry = exact_entry_for_version(known_versions, comment_version)
120
+ canonical = canonical_version_for(
121
+ resolved_version,
122
+ known_versions,
123
+ resolved_sha: resolved_sha,
124
+ comment_version: comment_version
125
+ )
126
+ return nil if comment_version.to_s == canonical
116
127
 
117
- if comment == resolved && resolved_entry && comment_entry
118
- preferred = entries_for_semantic_version(known_versions, comment).max_by { |known_entry| sort_key(known_entry) }
119
- preferred_version = preferred.fetch(:version)
120
- (preferred_version == comment_version.to_s) ? nil : preferred_version
121
- else
122
- return nil if comment_version.to_s == resolved_version.to_s
123
-
124
- resolved_version
125
- end
128
+ canonical
126
129
  end
127
130
 
128
- def exact_entry_for_version(versions, version)
129
- parsed = parse(version)
130
- return nil unless parsed
131
+ def entries_for_semantic_version(versions, version_obj)
132
+ versions.select { |entry| entry.fetch(:version_obj, nil) == version_obj }
133
+ end
131
134
 
132
- versions.find do |entry|
133
- entry.fetch(:version_obj, nil) == parsed &&
134
- entry.fetch(:version, nil).to_s == parsed.to_s
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)
145
+ resolved = parse(resolved_version)
146
+ return resolved_version.to_s unless resolved
147
+
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
135
160
  end
161
+ preferred = equivalents.max_by { |entry| sort_key(entry) }
162
+ preferred ? preferred[:version] : resolved.to_s
136
163
  end
137
164
 
138
- def entries_for_semantic_version(versions, version_obj)
139
- versions.select { |entry| entry.fetch(:version_obj, nil) == version_obj }
165
+ def strip_leading_v(text)
166
+ text.to_s.sub(/\A[vV]/, "")
140
167
  end
141
168
 
142
169
  def normalize_upgrade_level(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.6
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.6
305
- changelog_uri: https://github.com/kettle-dev/kettle-gha-pins/blob/v0.3.6/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.6
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