Module: StillActive::GithubClient
Overview
Repo signals (archived?, last commit date) for github.com-hosted gems. Wraps Octokit so the rest of the workflow dispatches to a provider with the same shape as GitlabClient, rather than reaching into Octokit inline. The Octokit dependency stays internal to this module.
Constant Summary collapse
- MAX_RATE_LIMIT_WAIT =
A rate-limit response whose reset is at most this many seconds away is waited out and retried; a longer wait (hourly-limit exhaustion) is not auto-taken and falls through to the caller’s rescue (warn + nil).
60
Instance Method Summary collapse
-
#commits_since_release(owner:, name:, version:) ⇒ Object
Commits on the default branch since the latest release’s tag: the “unreleased work” signal.
-
#repo_signals(owner:, name:) ⇒ Object
archived + last-activity date from a single repository call.
Instance Method Details
#commits_since_release(owner:, name:, version:) ⇒ Object
Commits on the default branch since the latest release’s tag: the “unreleased work” signal. GitHub’s compare endpoint returns ahead_by as a single scalar, so this is one cheap call. The git tag name isn’t carried by RubyGems, so resolve it from the version by trying the two ubiquitous forms (v7.0.1, 7.0.1) as the compare base; a wrong form 404s and we try the next. Returns nil when neither resolves (non-tagging repo, monorepo tag scheme we don’t guess). Only GithubClient implements this; the workflow dispatches by respond_to?, so GitLab/Forgejo simply don’t.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/still_active/github_client.rb', line 46 def commits_since_release(owner:, name:, version:) return if owner.nil? || name.nil? || version.nil? repo = "#{owner}/#{name}" ["v#{version}", version.to_s].each do |tag| return with_rate_limit_retry("unreleased-commits #{repo}") { StillActive.config.github_client.compare(repo, tag, "HEAD").ahead_by } rescue Octokit::NotFound # this tag form doesn't exist; fall through to try the next one end nil rescue Octokit::Error, Faraday::Error => e $stderr.puts("warning: unreleased-commits check failed for #{owner}/#{name}: #{e.class}") nil end |
#repo_signals(owner:, name:) ⇒ Object
archived + last-activity date from a single repository call. The repo object’s pushed_at (last push) stands in for the last-commit date: it matches the default-branch commit date to the day in practice, and folding the two signals into one call halves the per-gem GitHub requests. Returns {} when the repo can’t be read, so the caller leaves both signals blank.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/still_active/github_client.rb', line 24 def repo_signals(owner:, name:) return {} if owner.nil? || name.nil? repo = with_rate_limit_retry("repo #{owner}/#{name}") do StillActive.config.github_client.repository("#{owner}/#{name}") end return {} unless repo { archived: repo.archived, last_commit_date: as_time(repo.pushed_at, owner, name) } rescue Octokit::Error, Faraday::Error => e $stderr.puts("warning: repo signals failed for #{owner}/#{name}: #{e.class}") {} end |