source

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package source defines what baton reads about components.

Index

Constants

View Source
const (
	KindReleases = "releases"
	KindTags     = "tags"
)

Where a component's releases come from.

View Source
const (
	OrderVersion   = "version"
	OrderPublished = "published"
	OrderForge     = "forge"
)

Release orders.

View Source
const (
	LevelMajor = "major"
	LevelMinor = "minor"
	LevelPatch = "patch"
)

Trigger levels: the smallest SemVer change that owes work.

View Source
const MaxHistory = 100

MaxHistory caps how many commits PathHistory returns.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrNotFile  = errors.New("path is not a file")
	ErrHTTP     = errors.New("unexpected HTTP status")

	// ErrUnknowable means a question can't be answered for a past date
	// by design, such as the forge's current latest flag in a replay.
	ErrUnknowable = errors.New("can't be evaluated for a past date")
)

Errors a Source returns for answers that aren't API failures.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	SHA  string
	Date time.Time
}

Commit is a commit and its committer date.

type Filter

type Filter struct {
	Kind       string           // "releases" (default) or "tags"
	Tags       []*regexp.Regexp // every pattern must match
	Prerelease bool             // count prereleases
	Order      string           // OrderVersion (default), OrderPublished, or OrderForge
	Level      string           // triggers only; "" or LevelPatch counts every release
}

Filter says which of a component's releases count, and in what order.

func (*Filter) Latest

func (f *Filter) Latest(src Source, repo string, asOf, now time.Time) (*Release, error)

Latest returns the latest counted release, or nil if there is none.

func (*Filter) Releases

func (f *Filter) Releases(src Source, repo string, asOf, now time.Time) ([]Release, error)

Releases returns the counted releases published by asOf, latest first. For OrderForge the forge's flagged release comes first, then the rest by publish date; a past asOf returns ErrUnknowable.

type Release

type Release struct {
	Tag        string
	Published  time.Time
	Commit     string
	Prerelease bool // the forge's prerelease flag; tags have none
}

Release is a version of a component and when it was published. Commit is the commit the tag points to, when the listing provides it; otherwise TagCommit resolves it.

type Source

type Source interface {
	// Releases returns stable releases. kind is "releases" (GitHub
	// releases) or "tags" (version tags, dated by their commit).
	Releases(repo, kind string) ([]Release, error)
	// TagCommit returns the commit a tag points to, peeling annotated
	// tags.
	TagCommit(repo, tag string) (string, error)
	// CommitAt returns the default-branch commit as of a time.
	CommitAt(repo string, asOf time.Time) (string, error)
	// PathHistory returns up to MaxHistory default-branch commits that
	// touched path, committed at or before until, newest first.
	PathHistory(repo, path string, until time.Time) ([]Commit, error)
	// FlaggedLatest returns the release the forge marks as latest.
	FlaggedLatest(repo string) (Release, error)
	// File returns a file's content at ref; found is false on 404.
	File(repo, path, ref string) (content string, found bool, err error)
	// GetJSON fetches a JSON object from a URL.
	GetJSON(url string) (map[string]any, error)
}

Source is everything the probes read. The GitHub implementation is in internal/github; tests use the generated fake.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL