Documentation
¶
Overview ¶
Package checker resolves the latest upstream version for a pack and compares it against what the pack repo vendors.
It is one half of a two-implementation contract: `ichava/core`'s IconPackUpdateChecker powers host-app discovery through `php artisan ichava::ichava-core.check-updates`, and this drives the maintainer-side refresh. Where the two disagreed, see version.go.
Index ¶
- func AnyStale(results []Result) bool
- func CountErrored(results []Result) int
- func CountStale(results []Result) int
- func IsStale(current, latest string) bool
- func ParseLatest(source config.SourceConfig, payload any) string
- func ResolveReleaseURL(source config.SourceConfig, payload any, version string) string
- func TrimVersion(tag string) string
- func VersionCompare(a, b string) int
- type Checker
- type Fetcher
- type Result
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyStale ¶
AnyStale reports whether any result is behind upstream. `check` exits 1 on this, which is what makes it usable as a CI gate.
func CountErrored ¶
CountErrored returns how many results could not be resolved at all.
This exists because summarising on stale alone produces a false green: when every registry is unreachable nothing is *known* to be stale, so a naive "0 stale, therefore all up to date" reports success for a run that checked nothing. The Python reporter had exactly that bug, and it is the shape of failure this estate keeps paying for -- a green that means "did not look".
func CountStale ¶
CountStale returns how many results are behind upstream.
func IsStale ¶
IsStale reports whether current is behind latest. An unknown current is stale: a pack with no vendored version has never been synced.
func ParseLatest ¶
func ParseLatest(source config.SourceConfig, payload any) string
ParseLatest extracts the latest version from a registry payload.
Returns "" for a shape it does not recognise, which the caller reports as "could not parse latest" rather than treating as an error. Note that github-archive and script sources fall through here: neither declares a pollable endpoint, so neither has a latest version to find.
func ResolveReleaseURL ¶
func ResolveReleaseURL(source config.SourceConfig, payload any, version string) string
ResolveReleaseURL synthesises a clickable release link.
The order is checked, not incidental: a github-release payload's own html_url is authoritative and wins over anything synthesised from owner and repo, because a project can publish a release whose page is not at the conventional tag URL.
func TrimVersion ¶
TrimVersion strips a leading "v" from a tag.
Both existing implementations use a character-set trim -- PHP's ltrim($tag, 'vV ') and Python's lstrip("vV ") -- which also eats a leading "V" or space, and would turn "Version1" into "ersion1". That is a latent oddity rather than a live defect: no registry these packs poll emits such a tag. It is preserved rather than quietly corrected, because changing it here would put this port out of step with *both* of the implementations it has to agree with, and the PHP side is the one that decides.
func VersionCompare ¶
VersionCompare returns -1, 0 or 1 for a<b, a==b, a>b, matching PHP's version_compare with no operator.
When one version runs out of parts first, PHP decides by the next part of the longer one: a numeric part or one ranking at or above "#" makes the longer version greater (1.0.1 > 1.0), and anything below -- dev, alpha, beta, RC -- makes it lesser (1.0-rc1 < 1.0).
Types ¶
type Checker ¶
type Checker struct{ Fetch Fetcher }
Checker resolves upstream versions.
func (*Checker) CheckPack ¶
CheckPack resolves the latest version and compares it against the pack.
The comparison base is config.ResolvedCurrentVersion, which reads the pack repo's own record first. Comparing against this repository's current_version is what made the sync non-convergent (V49): the bump was written into the runner's throwaway checkout and never committed, so every run saw the same stale value and re-proposed the same refresh.
type Fetcher ¶
Fetcher is the HTTP surface the checker needs, narrowed so a test can supply a payload without a network or a live registry.
type Result ¶
type Result struct {
Package string
Current string
Latest string
Stale bool
ReleaseURL string
// Reason is set when Latest could not be established. It is not a failure:
// an unreachable registry leaves the pack unchanged rather than aborting a
// multi-pack run.
Reason string
}
Result is one pack's upstream status.