Documentation
¶
Overview ¶
Package sinks writes the in-flight tree to its destination.
Order matters and is set by the recipes: Filesystem, then VersionStamp, then GitBranch. Stamping after the commit would record a version that never shipped, and stamping into this repository rather than the pack repo is what made the sync non-convergent before (V49) -- the bump went into the runner's throwaway checkout and every run saw the same stale value.
Index ¶
Constants ¶
const ( LicenceStatusCopied = "copied" LicenceStatusMissing = "missing" LicenceStatusHandSupplied = "hand-supplied" )
The status values LicenceTexts reports in its metric.
const ( DefaultBranch = "chore/sync-upstream-{version}" DefaultCommitSubject = "chore(upstream): bump {pack} to v{new}" DefaultCommitBody = "Automated sync from upstream {pack} {old} -> {new}.\n\n" + "Generated by ichava/icon-sets-sync. See docs/maintainer-sync.md in that repository." )
Defaults matching the Python templates.
const HandSuppliedMarker = "SOURCE.md"
HandSuppliedMarker is the file whose presence makes a licence directory hand-maintained. It records where the hand-supplied text came from.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Discard ¶
Discard counts the SVGs a pipeline would have written, and writes nothing.
A pipeline needs at least one sink to run. A dry run of a pack whose only sink commits has none left once the committing sinks are dropped, and failing it there would make --dry-run useless for exactly the packs a person most wants to inspect before letting them commit.
type Filesystem ¶
type Filesystem struct {
pipeline.SinkKind
// Root is the destination, with {pack_root} and {version} interpolated.
Root string
// Incremental keeps what is already there. Off by default, which means
// the destination is wiped first -- that is what removes an icon upstream
// has deleted. An incremental sink would leave it in the pack forever.
Incremental bool
// MinRetention refuses to replace a populated destination with
// substantially fewer files, as a fraction of what is already there.
// Zero disables the check.
//
// Because the wipe is the point, it is also the hazard. Observed while
// building the aggregator refresh: iconoir's upstream reorganised into
// per-weight directories, so a refresh matching one of them would have
// replaced 1,671 committed icons with 1,383 -- deleting 288 without
// anything failing. A pack losing a sixth of a set to an upstream
// reshuffle should stop the run and ask, not proceed quietly on a Monday
// morning cron.
MinRetention float64
Log *slog.Logger
}
Filesystem copies the refreshed SVGs into the pack repo.
func (Filesystem) Name ¶
func (Filesystem) Name() string
type GitBranch ¶
type GitBranch struct {
pipeline.SinkKind
RepoRoot string
Branch string
CommitSubject string
CommitBody string
Base string
OpenPR bool
Git *gitx.Git
Log *slog.Logger
}
GitBranch commits the refreshed pack and opens a pull request.
type LicenceTexts ¶ added in v0.1.2
type LicenceTexts struct {
pipeline.SinkKind
Root string
Set string
// MissingReason lets a set whose upstream ships no licence file refresh
// anyway, with the reason recorded where it is configured (a manifest-pack set's
// licence_missing). The set's licence directory is then removed rather than
// left holding a text that no longer matches, and the gap is logged and
// reported as a metric on every run, unless the directory is hand-supplied
// (holds a SOURCE.md), which satisfies the exception.
MissingReason string
}
LicenceTexts writes the upstream's own licence and notice files, verbatim, into the pack beside the icons they cover.
The files are the ones FindLicences recorded at the root of the fetched tree, copied byte for byte under their upstream names. Never a template: the text that satisfies MIT's "this permission notice shall be included" is the upstream's own, copyright line and all.
Root is the destination for one set, with {pack_root} and {version} interpolated; the recipes use resources/assets/svg/licenses/<set>, which is not export-ignored, so the texts ship in every dist archive with the icons. The directory is replaced on each run, so a NOTICE upstream drops is dropped here too.
A directory holding a SOURCE.md is hand-maintained, and the sink never deletes or overwrites it. SOURCE.md is where a maintainer records where a hand-supplied text came from, for a set whose upstream ships none; replacing that directory on a scheduled run would destroy the only copy of the text in the pack. Such a set is reported as hand-supplied rather than missing, and a licence_missing exception it satisfies stops warning. If upstream later starts shipping licence files for that set, the folder is still kept and the run warns that upstream now ships its own, so a human reconciles the two: the hand-supplied text may be the better one (a fuller copyright line), and only a person can tell, so the sink neither switches silently nor fails a scheduled run over it.
An upstream with no licence file at its root fails the run, naming the set. Shipping icons whose licence text cannot be found is the defect this sink exists to end, so it is not reduced to a warning on a scheduled job.
func (LicenceTexts) Execute ¶ added in v0.1.2
func (s LicenceTexts) Execute(ctx *pipeline.Context) error
func (LicenceTexts) Name ¶ added in v0.1.2
func (LicenceTexts) Name() string
type VersionStamp ¶
VersionStamp records the fetched version in the pack repo's own config.
Into the pack repo, never back into this one. The GitBranch sink commits it alongside the assets, so the version and the SVGs it describes move in one commit and the next run compares against what actually shipped.
func (VersionStamp) Name ¶
func (VersionStamp) Name() string