release

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package release is the Release page's service: which clones have changes to release, and the release itself, through mage-x's magex. Prepare gathers a release's facts and shows the sheet Decide works out from them; Start gathers them again under the clone's lock, decides again, and runs magex through scriptrun; and once magex ends, whatever its exit status, the release is verified: origin is asked for the tag, and the clone for the branch it is on.

Index

Constants

View Source
const (
	// UnpushedSome is a branch with commits origin's lacks, which git couldn't count:
	// the clone has no origin/<branch>, and its head isn't an ancestor of origin's.
	UnpushedSome = -1

	// UnpushedUnknown is a branch git can't compare with origin's: the clone has no
	// origin/<branch>, nor the commit origin's branch points at.
	UnpushedUnknown = -2
)

The counts Unpushed holds when git can't give a number.

View Source
const (
	FollowFor   = 45 * time.Minute
	FollowPolls = 20
	FollowFirst = time.Minute
	FollowEvery = 3 * time.Minute
)

The limits of following a release's workflow on GitHub (§3.4.9): the first poll a minute after the follow starts, or resumes after a restart, then one every three minutes, at most FollowPolls of them over FollowFor, whichever comes first. Each poll is one GraphQL query of one point and, until the release is published, one REST request, so a release's follow spends at most 20 of each.

View Source
const FactsFor = 2 * time.Minute

FactsFor is how long the facts a sheet was shown serve the next Prepare or Start for the same clone and branch, so a choice on the sheet (a bump, the typed version, where it runs) asks GitHub and origin nothing. Prepare's Refresh reads them again at any age, and Start always reads them again under the clone's lock before anything runs.

View Source
const (
	// FollowChecksInterval is how often, unless the settings say otherwise, the follow reads
	// again the listed repositories whose checks were still running: the inbox's cadence
	// (inbox.FollowInterval). A round asks GitHub one status batch for them all and, for
	// those with a version off their newest commit, one comparison batch, about two points,
	// and nothing while none runs.
	FollowChecksInterval = 45 * time.Second
)

The follow of the Release page's repositories whose newest commit's checks are running: the list is read again in full only when the user asks, so a row whose checks were running when it was read would otherwise say so until then.

Variables

View Source
var (
	// ErrNotARelease is returned by ReleaseResult for a run that isn't a release.
	ErrNotARelease = errors.New("the run isn't a release")

	// ErrNoResult is returned by ReleaseResult for a release with no result: one still
	// going, or one that ended before magex did, as when it couldn't start.
	ErrNoResult = errors.New("the release has no result")
)
View Source
var (
	// ErrNotSetUp is returned by Prepare and Start on a Service built without what a
	// release needs: git, and the runner.
	ErrNotSetUp = errors.New("releases are not set up")

	// ErrInvalidRequest is returned for a request naming no repository, or a bump, a
	// version, or a place to run that isn't one.
	ErrInvalidRequest = errors.New("invalid release request")

	// ErrNoClone is returned when no clone in the repository locations has the repository
	// as its origin.
	ErrNoClone = errors.New("no clone of the repository")

	// ErrNotReady is returned by Start when the facts, gathered again, block the release:
	// the sheet shows them again.
	ErrNotReady = errors.New("the release can't start")

	// ErrVersionMoved is returned by Start when the version the release would make is no
	// longer the one the button showed: the sheet shows the new one.
	ErrVersionMoved = errors.New("the version to release moved")

	// ErrRejected is returned by Start for a release the sheet should never have started:
	// a major without its typed confirmation, without the go.mod box ticked where the
	// module path needs it, or with a magex that can't be told which version to make. It
	// is logged as a bug.
	ErrRejected = errors.New("the release was refused")
)
View Source
var ErrSignedOut = errors.New("not signed in to GitHub")

ErrSignedOut is returned when no one is signed in to GitHub, so nothing could be asked.

Functions

This section is empty.

Types

type AfterMerge

type AfterMerge struct {
	// Offer reports that the toast carries Release <repo>….
	Offer bool `json:"offer"`

	// Repo is the repository, "owner/name", Dir its clone, with ~, and Branch the branch
	// the pull request merged into, which the sheet releases. Each is "" without Offer.
	Repo   string `json:"repo"`
	Dir    string `json:"dir"`
	Branch string `json:"branch"`
}

AfterMerge says whether the toast that reports a merge in the review sheet offers to release the repository (§3.4.8). When Offer is set, its action opens Scripts → Release and the repository's sheet, with Repo, Dir, and Branch as the sheet's PrepareRequest.

type BranchChoice

type BranchChoice struct {
	Name    string `json:"name"`
	Default bool   `json:"default"`
}

BranchChoice is a branch the sheet's menu offers (D10).

type Bump

type Bump string

Bump is which part of the version a release raises.

const (
	// BumpPatch raises the patch version: v1.4.2 → v1.4.3.
	BumpPatch Bump = "patch"

	// BumpMinor raises the minor version: v1.4.2 → v1.5.0.
	BumpMinor Bump = "minor"

	// BumpMajor raises the major version: v1.4.2 → v2.0.0.
	BumpMajor Bump = "major"
)

The bumps a release offers.

func (Bump) Valid

func (b Bump) Valid() bool

Valid reports whether b is one of the bumps.

type BumpOffer

type BumpOffer struct {
	Bump    Bump   `json:"bump"`
	Version string `json:"version"`
	Offered bool   `json:"offered"`
	Note    string `json:"note"`
	Fixes   []Fix  `json:"fixes"`
}

BumpOffer is one of the sheet's cards: the version a bump makes, and whether it is offered; when it isn't, Note may say why, with Fixes.

type BumpResult

type BumpResult struct {
	// From and To are the version bumped from and to, as vX.Y.Z; Bump is patch, minor,
	// or major; Expect is the version expect= pinned, or "".
	From   string `json:"from"`
	To     string `json:"to"`
	Bump   string `json:"bump"`
	Expect string `json:"expect"`

	// DryRun reports a dry run.
	DryRun bool `json:"dryRun"`

	// Tag is the tag made, or "", and Commit the full ID of the commit it points at.
	Tag    string `json:"tag"`
	Commit string `json:"commit"`

	// Pushed is true only when origin has the tag at that commit.
	Pushed bool `json:"pushed"`

	// StartBranch is the branch the clone was on, and Branch the one it ended on; ""
	// is a detached HEAD.
	StartBranch string `json:"startBranch"`
	Branch      string `json:"branch"`

	// Warnings are the warnings magex printed, as plain text, never nil.
	Warnings []string `json:"warnings"`

	// Error is the error the run failed with, or "".
	Error string `json:"error"`
}

BumpResult is the outcome magex 1.30.1 and later print with json=true: one JSON object on a line of its own, the last line of stdout, on success and on failure. A step the run didn't reach leaves its fields empty. The field names are mage-x's (bumpResult in pkg/mage/version_bump_json.go), which it keeps stable for scripts.

type Candidate

type Candidate struct {
	// Repo is the repository, "owner/name", and Dir its clone, with ~ for home.
	Repo string `json:"repo"`
	Dir  string `json:"dir"`

	// Group is where it's listed, and Reason, for GroupCantRelease, says why. A row in
	// GroupMuted may hold nothing but Repo and Dir, when GitHub wasn't asked about it.
	Group  Group  `json:"group"`
	Reason string `json:"reason"`

	// Version is the newest version tag, or "" for none, and Ahead the commits on the
	// default branch since it, the newest of them in Commits.
	Version string   `json:"version"`
	Ahead   int      `json:"ahead"`
	Commits []Commit `json:"commits"`

	// DefaultBranch, Headline, HeadAt, and Checks describe the default branch's newest
	// commit; HeadAt is RFC 3339, or "".
	DefaultBranch string `json:"defaultBranch"`
	Headline      string `json:"headline"`
	HeadAt        string `json:"headAt"`
	Checks        Checks `json:"checks"`

	// Clone is the clone's state, for the unreleased group only, or nil.
	Clone *CloneState `json:"clone"`
	// contains filtered or unexported fields
}

Candidate is a repository the Release page lists, with the clone it releases from.

type Candidates

type Candidates struct {
	Repos         []Candidate `json:"repos"`
	WithoutGitHub int         `json:"withoutGitHub"`
	CheckedAt     string      `json:"checkedAt"`
	Error         string      `json:"error"`
	Kept          bool        `json:"kept"`
	Refreshing    bool        `json:"refreshing"`
}

Candidates is the Release page's list: every clone with a GitHub origin, grouped, and how many clones have none. CheckedAt is when GitHub was last asked, RFC 3339. Error says why the last refresh failed, while the list from before it is still shown.

Kept reports the list kept from a past start, shown at once after a restart: GitHub hasn't been read since, and CheckedAt says how old it is. Refreshing reports a read of GitHub under way behind the page; event.ReleasesUpdated says when it lands.

type Check

type Check struct {
	ID    CheckID    `json:"id"`
	State CheckState `json:"state"`
	Text  string     `json:"text"`

	// Fixes are the actions beside it, and Commands the commands it offers to copy, which
	// the app never runs, each branch or tag name in them, which can hold $(…) or
	// backticks, quoted as textutil.ShellWord quotes it.
	Fixes    []Fix    `json:"fixes"`
	Commands []string `json:"commands"`

	// Link is what FixView opens, and RunID the run FixWatch opens.
	Link  string `json:"link"`
	RunID int64  `json:"runId"`
}

Check is one line of the sheet's checks.

type CheckID

type CheckID string

CheckID names one of the release sheet's checks (§3.4.3).

const (
	// CheckTool is magex: there, on, and new enough.
	CheckTool CheckID = "tool"

	// CheckRepo is the repository on GitHub: read, shown to the user, not archived, with
	// commits.
	CheckRepo CheckID = "repo"

	// CheckOrigin is the clone: git reads it, and its origin is the repository.
	CheckOrigin CheckID = "origin"

	// CheckAccess is the user's access: enough to push a tag.
	CheckAccess CheckID = "access"

	// CheckInProgress is git in the middle of something: a rebase, a merge, a
	// cherry-pick, or a revert.
	CheckInProgress CheckID = "inProgress"

	// CheckDirty is uncommitted changes, which magex refuses.
	CheckDirty CheckID = "dirty"

	// CheckDetached is a clone on a bare commit rather than a branch.
	CheckDetached CheckID = "detached"

	// CheckWhere is the branch the clone is on, and whether git can switch to the
	// release's.
	CheckWhere CheckID = "where"

	// CheckBranch is the release's branch: one Release offers, and in the clone.
	CheckBranch CheckID = "branch"

	// CheckUpstream is the branch following origin's, which magex's pull needs.
	CheckUpstream CheckID = "upstream"

	// CheckUnpushed is commits on the branch that origin's lacks.
	CheckUnpushed CheckID = "unpushed"

	// CheckLocalOnly is a version tag only in the clone, which magex would skip.
	CheckLocalOnly CheckID = "localOnly"

	// CheckBehind is origin's branch having commits the clone's lacks.
	CheckBehind CheckID = "behind"

	// CheckReach is origin answering with the user's git credentials.
	CheckReach CheckID = "reach"

	// CheckNothingNew is a version already on origin's newest commit.
	CheckNothingNew CheckID = "nothingNew"

	// CheckChecks is the checks on the default branch's newest commit.
	CheckChecks CheckID = "checks"

	// CheckBusy is another job holding the clone.
	CheckBusy CheckID = "busy"

	// CheckSigning is git signing the tag, and whether it can without a terminal.
	CheckSigning CheckID = "signing"

	// CheckShell is the login shell's environment, read or not.
	CheckShell CheckID = "shell"

	// CheckHooks is the clone's hooks that a release runs.
	CheckHooks CheckID = "hooks"
)

The checks, in the order the sheet lists them.

type CheckState

type CheckState string

CheckState is how a check came out: ✓ and ℹ only inform, ⚠ warns, and ✗ blocks.

const (
	CheckOK    CheckState = "ok"
	CheckInfo  CheckState = "info"
	CheckWarn  CheckState = "warn"
	CheckBlock CheckState = "block"
)

The states a check can be in.

type Checker

type Checker interface {
	CloneState(ctx context.Context, dir, branch, remoteHead string, tags []Tag) CloneState
}

Checker reads a clone's state for its row on the page, with read-only git: the branch it's on, its uncommitted files, how it stands with branch on origin (whose newest commit GitHub says is remoteHead), and the version tags only it has, which tags (GitHub's newest) tell. It never fails: what it can't read, it marks unreadable.

type Checks

type Checks string

Checks is the rollup state of the checks on a commit, as GitHub reports it.

const (
	ChecksNone     Checks = ""
	ChecksSuccess  Checks = "SUCCESS"
	ChecksPending  Checks = "PENDING"
	ChecksExpected Checks = "EXPECTED"
	ChecksFailure  Checks = "FAILURE"
	ChecksError    Checks = "ERROR"
)

The checks' states; ChecksNone is a commit without checks.

type ChecksFollower

type ChecksFollower struct {
	// contains filtered or unexported fields
}

ChecksFollower reads again, as often as its every says (the user's setting, FollowChecksInterval when nil; off at zero), the Release page's repositories whose newest commit's checks are running (followChecks), as a desktop worker. Wake makes it read the setting again at once. It isn't bound, and neither is what it calls. A round that arrives while one is still running is skipped; failures are logged, and a panicking round is recovered, so it keeps going until its context is canceled.

func NewChecksFollower

func NewChecksFollower(s *Service, every periodic.Every, logger *slog.Logger) *ChecksFollower

NewChecksFollower returns a ChecksFollower over s, as often as every says, logging failures to logger. A nil every follows every FollowChecksInterval, and a nil logger discards the failures.

func (*ChecksFollower) Run

func (f *ChecksFollower) Run(ctx context.Context)

Run follows now and then as often as every says until ctx is canceled, then waits for a round in flight to return. Its rounds find nothing to read until the page has read the list from GitHub in this run.

func (*ChecksFollower) Wake

func (f *ChecksFollower) Wake()

Wake has the follower read how often to follow again, as when the user changed it.

type Choice

type Choice struct {
	// Bump is the release's bump, patch when empty (D11), and Branch the branch to
	// release, the default on GitHub when empty.
	Bump   Bump
	Branch string

	// Typed is what the user typed to confirm a major, and AllowModulePath reports the box
	// ticked to release a major that go.mod doesn't name.
	Typed           string
	AllowModulePath bool

	// RunsIn is where the run goes, and Terminal the terminal's name for a run there, as
	// in "iTerm2", or "" to say "your terminal".
	RunsIn   integrationprefs.RunsIn
	Terminal string
}

Choice is what the user chose on the sheet.

type Clone

type Clone struct {
	Dir    string
	Origin repo.Name
	OnHub  bool
}

Clone is a clone the candidates are listed from: its absolute folder, and its origin, when origin is a GitHub repository.

type CloneFacts

type CloneFacts struct {
	// Dir is the clone's folder, absolute.
	Dir string

	// Error says why git couldn't read the clone, or is "" when it could.
	Error string

	// OriginMatches reports that the clone's origin is the repository.
	OriginMatches bool

	// InProgress is what git is in the middle of, and Changes the uncommitted files.
	InProgress gitread.Operation
	Changes    []string

	// Branch is the branch checked out, and Detached reports a detached HEAD instead.
	Branch   string
	Detached bool

	// Elsewhere are the clone's other worktrees, with ~, that have the release's branch
	// checked out.
	Elsewhere []string

	// LocalHead is the release's branch in the clone, and TrackingHead origin/<branch>
	// as the clone last learned it; each is "" when the clone has none.
	LocalHead    string
	TrackingHead string

	// Upstream is what the branch is set to follow.
	Upstream gitread.Upstream

	// Unpushed counts the branch's commits origin's lacks, or is UnpushedSome or
	// UnpushedUnknown. Behind reports origin's branch has commits the clone's lacks.
	Unpushed int
	Behind   bool

	// Reached reports origin answered, and ReachError, when it didn't, what git said.
	Reached    bool
	ReachError string

	// RemoteHeads are origin's branches, and RemoteTags its tags, when it answered.
	RemoteHeads map[string]string
	RemoteTags  map[string]gitread.RemoteTag

	// LocalTags are the clone's version tags.
	LocalTags []string

	// Signing is whether, and how, git signs the release's tag here.
	Signing SigningFacts

	// Hooks are the hooks a release can run that the clone has: pre-push, post-checkout.
	Hooks []string

	// ShellRead reports that the login shell's environment was read.
	ShellRead bool

	// Busy reports another job holds the clone, and Holder which.
	Busy   bool
	Holder clonelock.Holder

	// ModulePath is go.mod's module path, or "" when the clone isn't a Go module.
	ModulePath string
}

CloneFacts is what read-only git, and a few files, say of the clone the release runs in.

type CloneState

type CloneState struct {
	Branch     string   `json:"branch"`
	Detached   bool     `json:"detached"`
	Dirty      int      `json:"dirty"`
	NotPushed  int      `json:"notPushed"`
	Behind     bool     `json:"behind"`
	LocalOnly  []string `json:"localOnly"`
	Unreadable bool     `json:"unreadable"`
}

CloneState is what a clone's read-only checks found, for the Release page's row: the branch it's on, its uncommitted files, its commits not on GitHub and those it lacks, and the version tags only it has.

type Clones

type Clones interface {
	Roots(ctx context.Context) (localrepos.Roots, error)
	Clones(ctx context.Context, roots localrepos.Roots) ([]Clone, error)
}

Clones finds the clones: Roots is the clone root and the other repository locations as set now, a cheap read, and Clones lists the clones in them, the clone root's first. Core adapts the settings and localrepos.

type Commit

type Commit struct {
	OID      string    `json:"oid"`
	Headline string    `json:"headline"`
	At       time.Time `json:"at"`
}

Commit is a commit as the Release page shows it.

type Compare

type Compare struct {
	Ahead   int
	Commits []Commit
}

Compare is how far a branch is ahead of a tag: the count, and the newest commits.

type CompareRequest

type CompareRequest struct {
	Repo   repo.Name
	Tag    string
	Branch string
}

CompareRequest asks how far a branch is ahead of a tag.

type Config

type Config struct {
	GitHub  GitHub
	Clones  Clones
	Checker Checker

	// Git reads the clone a release runs in, before it starts and under its lock, and
	// finds where the release left the tag and the clone once it ends.
	Git *gitread.Git

	// Origins reads which repository a clone's origin is, Tools what the app knows of
	// magex, and Locks which job holds a clone: the app's one *clonelock.Set.
	Origins OriginReader
	Tools   ToolSource
	Locks   LockHolders

	// Env returns the login shell's environment, and whether it was read
	// (shellenv.Reader.Env): a release in the app runs with it, and so do ssh-add and
	// ssh-keygen, which Runner runs. Both default as GatherConfig's do.
	Env    func() ([]string, bool)
	Runner func(env []string) execpath.Runner

	// Ready, when set, returns a channel closed once the login shell's environment has
	// first been read (shellenv.Reader.Ready). A release from before a restart waits for
	// it before it is verified, so origin is asked with the user's own ssh agent.
	Ready func() <-chan struct{}

	// Runs starts a release's run: the scriptrun engine. Places reads where runs go; without
	// it they go in the app.
	Runs   Runs
	Places Places

	// History reads a run back from the runner's history, for ReleaseResult: the scriptrun
	// Service.
	History RunHistory

	// Notifier tells the user of each release that reaches GitHub, and of each its workflow
	// published or failed; without it, nothing is told.
	Notifier Notifier

	// Workflows reads how a release's workflow on GitHub goes, and Records reads the
	// releases that ended and writes how each one's follow goes into its record: the
	// Follower needs both, and without either no release is followed.
	Workflows Workflows
	Records   RunRecords

	// AfterMerge reads whether a merge offers a release, and Branches the default branch
	// the app last stored for a repository, which OfferAfterMerge reads with Tools and the
	// clones. Without AfterMerge, a merge offers nothing.
	AfterMerge MergeSetting
	Branches   DefaultBranches

	// Terminal opens the user's terminal in a clone, for a check's Open in terminal.
	// Without it, OpenTerminal says the terminal can't be opened here.
	Terminal scriptrun.FolderOpener

	// Keeper keeps the last list between starts, so the page shows it at once while the
	// Refresher reads GitHub again. Without it, nothing is kept.
	Keeper Keeper

	// Rules reads the pinned and muted repositories and orgs: a muted one is listed in
	// GroupMuted and never asked about, and a pinned one comes first in its group. Without
	// it, nothing is pinned or muted.
	Rules RuleSource

	Home   string
	Clock  clock.Clock
	Events event.Sink
	Logger *slog.Logger
}

Config holds a Service's dependencies. GitHub and Clones are required; Prepare and Start also need Git, Origins, and Runs.

type DefaultBranches

type DefaultBranches interface {
	DefaultBranch(ctx context.Context, name repo.Name) (string, error)
}

DefaultBranches reads the default branch the app last stored for a repository, as the inbox read it from GitHub, without asking GitHub again: "" when it has none. Core adapts the inbox's store.

type Facts

type Facts struct {
	Tool   ToolFacts
	Repo   RepoFacts
	Clone  CloneFacts
	Choice Choice
}

Facts is everything a release's offer depends on, gathered fresh each time: Decide works the offer out from them alone.

type FailedCheck

type FailedCheck struct {
	// Name is the check run's name, or the commit status's context.
	Name string

	// Status reports a commit status, as a coverage service posts, rather than a check run:
	// the commit's checks page on GitHub lists only check runs.
	Status bool
}

FailedCheck is a check run or commit status that failed on a commit.

type Failure

type Failure struct {
	// Kind is what happened, and Heading says it in a sentence.
	Kind    FailureKind `json:"kind"`
	Heading string      `json:"heading"`

	// Quote is the line of the output the heading quotes, or "".
	Quote string `json:"quote"`

	// Bug reports a failure only a bug in the app can cause, to report as one.
	Bug bool `json:"bug"`
}

Failure is a failed release's heading: what happened, in words.

func ExplainFailure

func ExplainFailure(in FailureInput) Failure

ExplainFailure names what stopped a release, from magex's ❌ Error: line and the other signs in its output, with the headings of the plan's §5.11.7. The version and branch a heading names are the input's, or else what magex said; a tag GitHub refused is the one magex made. Anything it can't name reads "magex stopped:" and magex's last error line.

type FailureInput

type FailureInput struct {
	// Output is what the output reader read, the whole of it.
	Output Output

	// End is how the run ended.
	End scriptrun.Ending

	// Version is the version the sheet showed, such as v1.4.3, and Branch the branch it
	// released from, such as master.
	Version string
	Branch  string
}

FailureInput is what ExplainFailure reads: what magex said, how the run ended, and the release the sheet started.

type FailureKind

type FailureKind string

FailureKind names what stopped a release, one for each heading.

const (
	// FailureUnconfirmed is magex asking to confirm a major bump, which the app always
	// does: a bug in the app.
	FailureUnconfirmed FailureKind = "unconfirmed"

	// FailureMoved is a version tagged on GitHub between the sheet and the run, which
	// expect= made magex refuse.
	FailureMoved FailureKind = "moved"

	// FailureDirty is a clone with uncommitted changes.
	FailureDirty FailureKind = "dirty"

	// FailureNothingNew is a newest commit that already has a version tag.
	FailureNothingNew FailureKind = "nothingNew"

	// FailureNoBranch is a branch neither the clone nor origin has.
	FailureNoBranch FailureKind = "noBranch"

	// FailureUnsafe is magex's safety check refusing the bump.
	FailureUnsafe FailureKind = "unsafe"

	// FailureTaken is the version on GitHub at another commit.
	FailureTaken FailureKind = "taken"

	// FailureTimeout is a git step past magex's 30-second limit.
	FailureTimeout FailureKind = "timeout"

	// FailureMidPull is magex stopped while it pulled, which can leave a rebase, or while
	// it fast-forwarded the branch (ff-only), which can't.
	FailureMidPull FailureKind = "midPull"

	// FailureSigning is git unable to sign the tag, with gpg or ssh.
	FailureSigning FailureKind = "signing"

	// FailureAuth is origin refusing the git credentials.
	FailureAuth FailureKind = "auth"

	// FailureRefused is GitHub refusing the tag: a tag ruleset, or a protected tag.
	FailureRefused FailureKind = "refused"

	// FailureHook is the clone's pre-push hook stopping the tag.
	FailureHook FailureKind = "hook"

	// FailureOther is anything else, told in magex's own words.
	FailureOther FailureKind = "other"
)

The kinds of failure, in the order they are told apart.

type Fix

type Fix string

Fix is an action the sheet offers beside a check.

const (
	// FixOpenSettings opens Settings → Integrations.
	FixOpenSettings Fix = "openSettings"

	// FixUpdate updates magex.
	FixUpdate Fix = "update"

	// FixOpenTerminal opens the user's terminal in the clone, and runs nothing there.
	FixOpenTerminal Fix = "openTerminal"

	// FixCheckAgain gathers the facts again.
	FixCheckAgain Fix = "checkAgain"

	// FixView opens Check.Link.
	FixView Fix = "view"

	// FixWatch opens the run that holds the clone, Check.RunID.
	FixWatch Fix = "watch"
)

The fixes a check offers.

type Follow

type Follow struct {
	// State is where it is.
	State FollowState `json:"state"`

	// Since is when it started, Until when it stops at the latest, and Ended when it
	// stopped, or "" while it goes on, each RFC 3339; Minutes is how long it went on, in
	// whole minutes, once it stopped.
	Since   string `json:"since"`
	Until   string `json:"until"`
	Ended   string `json:"ended"`
	Minutes int    `json:"minutes"`

	// Polls counts the polls it made.
	Polls int `json:"polls"`

	// RunsDone reports the last poll found every one of the tag's runs ended well, and no
	// release published: the next poll that finds no release published either stops the
	// follow (FollowUnpublished).
	RunsDone bool `json:"runsDone"`

	// Workflow is the name of the tag's workflow that failed, for FollowFailed, or "".
	Workflow string `json:"workflow"`

	// URL is the page its line links to: the release's once published; the failed run's,
	// or else the tag's Actions runs, once failed; the repository's releases once the tag's
	// runs ended with none published; the tag's Actions runs once no workflow ran, or it
	// stopped at its limits; and "" while it goes on.
	URL string `json:"url"`
}

Follow is how following a release's workflow on GitHub goes. It is kept in the release's result (Result.Follow), in its run's record, so a follow resumes after a restart within the same limits.

type FollowState

type FollowState string

FollowState is where following a release's workflow on GitHub is.

const (
	// FollowFollowing is a follow going on, within its limits.
	FollowFollowing FollowState = "following"

	// FollowPublished is a release GitHub published: it has it, published, and not a draft.
	FollowPublished FollowState = "published"

	// FollowFailed is a release one of whose tag's workflow runs failed, once all of them
	// ended without it being published.
	FollowFailed FollowState = "failed"

	// FollowNoWorkflow is a tag no workflow ran for by the third poll, with no release
	// published: there's nothing to follow.
	FollowNoWorkflow FollowState = "noWorkflow"

	// FollowUnpublished is a tag whose workflow runs all ended well, with no release
	// published a poll later.
	FollowUnpublished FollowState = "unpublished"

	// FollowTimedOut is a follow that reached its limits with none of those: nothing is
	// assumed.
	FollowTimedOut FollowState = "timedOut"
)

The states of a follow.

type Follower

type Follower struct {
	// contains filtered or unexported fields
}

Follower follows each release that reached GitHub until GitHub publishes it, one of the tag's workflows fails, the answer is otherwise settled, or the follow reaches its limits (§3.4.9): it polls GitHub a minute after the follow starts, then every three minutes, at most FollowPolls times over FollowFor. Each poll's count, and how the follow ended, are written into the release's record, so the run's result and Recent say so, and a follow cut off by a quit resumes on the next start within the same limits. A release published, or whose workflow failed, is told to the user (release_published, release_failed); any other end only says so in the result. It reads the real clock throughout; tests run it in a synctest bubble. The desktop shell runs it as deferred work, from the first paint until quit; it is not bound.

func NewFollower

func NewFollower(s *Service) *Follower

NewFollower returns the worker that follows s's releases on GitHub.

func (*Follower) Run

func (f *Follower) Run(ctx context.Context)

Run resumes the follows the releases' records say go on, then follows each release handed to it as it ends, until ctx ends, and returns once every follow has stopped. A follow the quit cut off stays recorded as going on, for the next start. Without GitHub's workflows or the runs' records, it follows nothing.

type GatherConfig

type GatherConfig struct {
	Git     *gitread.Git
	GitHub  GitHub
	Origins OriginReader
	Tools   ToolSource
	Locks   LockHolders

	// Env returns the environment ssh-add and ssh-keygen run with, and whether it is the
	// login shell's (shellenv.Reader.Env). It defaults to the app's own, counted as read.
	Env func() ([]string, bool)

	// Runner returns what runs ssh-add and ssh-keygen with env. It defaults to an
	// execpath.Exec that finds them on env's PATH.
	Runner func(env []string) execpath.Runner

	// Home is the user's home folder, for ~ paths.
	Home string
}

GatherConfig holds a Gatherer's dependencies. Git, GitHub, and Origins are required.

type GatherRequest

type GatherRequest struct {
	Repo   repo.Name
	Dir    string
	Choice Choice
	Locked bool

	// GitHub, when set, is what GitHub said of the repository moments ago, used as it is
	// rather than asked again: Start, under the clone's lock, reads again only what the
	// release's version and readiness hang on, origin and the clone.
	GitHub *RepoFacts
}

GatherRequest names what to gather: the repository, its clone's folder, the user's choice, and whether the caller already holds the clone's lock, as Start does, so the lock it holds isn't counted as another job's.

type Gatherer

type Gatherer struct {
	// contains filtered or unexported fields
}

Gatherer gathers a release's facts, reading GitHub, origin, and the clone at once.

func NewGatherer

func NewGatherer(cfg GatherConfig) *Gatherer

NewGatherer returns a Gatherer over cfg.

func (*Gatherer) Gather

func (g *Gatherer) Gather(ctx context.Context, req GatherRequest) (Facts, error)

Gather reads every fact a release's offer depends on: magex, the repository on GitHub (unless req.GitHub gives it), origin (one ls-remote, which takes longest), and the clone, all at once. What it can't read becomes a fact, as an error the offer shows, so it fails only when ctx ends.

type GitChecker

type GitChecker struct {
	Git *gitread.Git
}

GitChecker reads a clone's state for the Release page with gitread's read-only commands (Checker). It asks nothing of origin: what the clone lacks is judged from GitHub's answer, so a row costs no network.

func (GitChecker) CloneState

func (c GitChecker) CloneState(ctx context.Context, dir, branch, remoteHead string, tags []Tag) CloneState

CloneState reads the clone at dir: the branch it's on, its uncommitted files, how its branch stands with branch on GitHub (whose newest commit is remoteHead), and the version tags only it has. A version tag counts as only on this Mac when GitHub's newest tags lack it and it is above their highest version, as magex would then skip it and leave a gap; GitHub's list holds only the newest tags, so an older one isn't judged. What it can't read, it marks Unreadable, and it never fails.

type GitHub

type GitHub interface {
	ReleaseStatus(ctx context.Context, repos []repo.Name, answered func(n int)) (map[string]RepoStatus, error)
	ReleaseCompare(ctx context.Context, reqs []CompareRequest, answered func(n int)) (map[string]Compare, error)
	RepoStatus(ctx context.Context, name repo.Name) (status RepoStatus, ok bool, err error)
}

GitHub is what Release reads from GitHub: each repository's status, then, for those with a version, how far the default branch is ahead of it. Both key their answers by repo.Name.Key(), and leave out a repository GitHub can't find. answered, when set, is told as GitHub answers each batch, with how many of repos or reqs it held, from any goroutine; nil hears nothing. RepoStatus is the sheet's read of one repository, its status with the newest commit's failed checks (RepoStatus.Failing) in the same one query; ok is false when GitHub can't find it. Core adapts the client.

type Group

type Group string

Group is where the Release page lists a repository.

const (
	// GroupUnreleased has commits on its default branch since its newest version tag.
	GroupUnreleased Group = "unreleased"

	// GroupUpToDate has its newest version tag on its newest commit, or nothing since.
	GroupUpToDate Group = "upToDate"

	// GroupNoReleases has no vX.Y.Z tag yet.
	GroupNoReleases Group = "noReleases"

	// GroupCantRelease is archived, read-only to the user, or not found on GitHub.
	GroupCantRelease Group = "cantRelease"

	// GroupMuted is a repository the user muted, itself or its org (see the reporules
	// package): listed apart, and never asked about.
	GroupMuted Group = "muted"
)

The groups, in the order the page shows them.

type Intent

type Intent struct {
	// Version is the version the button showed, and Bump the bump that makes it.
	Version string `json:"version"`
	Bump    Bump   `json:"bump"`

	// Branch is the branch released from, and Original the one the clone was on when the
	// sheet opened, which magex switches back to.
	Branch   string `json:"branch"`
	Original string `json:"original"`

	// Head is the commit the sheet showed, the newest on origin's branch then.
	Head string `json:"head"`

	// FastForward reports that magex was told to update the branch by fast-forward only
	// (ff-only), so it never rebases there.
	FastForward bool `json:"fastForward"`
}

Intent is what a release sets out to do, written into its run's result as it starts (scriptrun.Spec.Intent), so that a release cut short, or left running when the app quit, is still verified against it.

type Keeper

type Keeper interface {
	Get(ctx context.Context, key string) (value string, ok bool, err error)
	Set(ctx context.Context, key, value string) error
}

Keeper keeps the last list between starts: core's prefs store. The service reads and writes keptKey alone.

type LockHolders

type LockHolders interface {
	Holder(path string) (clonelock.Holder, bool)
}

LockHolders says which job holds a clone, if any: a *clonelock.Set.

type MajorOffer

type MajorOffer struct {
	// Version is the major's version, and FirstStable reports v1.0.0, from v0.x.
	Version     string `json:"version"`
	FirstStable bool   `json:"firstStable"`

	// ModulePath is the clone's go.mod module, or "" when it isn't a Go module. When Go
	// couldn't install Version from it, ModuleWant is the path it needs, and ModuleText
	// says so; only Choice.AllowModulePath gets past it.
	ModulePath string `json:"modulePath"`
	ModuleWant string `json:"moduleWant"`
	ModuleText string `json:"moduleText"`

	// Confirmed reports the user typed Version.
	Confirmed bool `json:"confirmed"`
}

MajorOffer is the careful form a major takes (§3.4.4).

type MergeSetting

type MergeSetting interface {
	OfferAfterMerge(ctx context.Context) (bool, error)
}

MergeSetting reads whether merging a pull request in the review sheet offers a release: the integrations.offerAfterMerge setting. Core adapts the settings.

type Notice

type Notice struct {
	// Repo is the repository released.
	Repo repo.Name

	// Title says what happened ("v1.4.3 is on GitHub", "acme-org/sdk v1.4.3 is
	// published"), Body what follows it, as where the tag went ("Tagged a1b2c3d on
	// master."), or "", and URL is the page a click opens: the tag's, the release's, or the
	// failed run's on GitHub.
	Title string
	Body  string
	URL   string
}

Notice is what the user is told of a release.

type Notifier

type Notifier interface {
	Released(ctx context.Context, n Notice)
	Published(ctx context.Context, n Notice)
	WorkflowFailed(ctx context.Context, n Notice)
}

Notifier tells the user of a release: its tag reached GitHub (release_done), its workflow published it (release_published), or its workflow failed (release_failed), each a notification in the log, and its banner when the user has the kind on (§5.19). Core adapts the notify package's Dispatcher. Each must return promptly; a failure is its own to log.

type Offer

type Offer struct {
	// Repo is the repository, "owner/name".
	Repo string `json:"repo"`

	// Branch is the release's branch, Branches those the menu offers, and BranchNote what
	// the sheet says of a branch that isn't the default.
	Branch     string         `json:"branch"`
	Branches   []BranchChoice `json:"branches"`
	BranchNote string         `json:"branchNote"`

	// Current is the branch the clone is on, "" when detached, and Head the commit
	// origin's branch is at, which the release tags.
	Current string `json:"current"`
	Head    string `json:"head"`

	// Checks are the sheet's checks, in order.
	Checks []Check `json:"checks"`

	// Bump is the chosen bump and Version the version it makes; Bumps are every card,
	// and Major the careful form a major takes.
	Bump    Bump        `json:"bump"`
	Version string      `json:"version"`
	Bumps   []BumpOffer `json:"bumps"`
	Major   MajorOffer  `json:"major"`

	// Ready reports the release can start, and Anyway that it would despite a warning.
	Ready  bool `json:"ready"`
	Anyway bool `json:"anyway"`

	// Button is the button's label, and Sentence what will happen, said above it.
	Button   string `json:"button"`
	Sentence string `json:"sentence"`

	// Argv is what the release runs, magex's path first, or empty without a magex to run.
	Argv []string `json:"argv"`
}

Offer is what Decide works out: the sheet's branches, checks, and cards, whether the release can start, and what it would run.

func Decide

func Decide(f Facts) Offer

Decide works the release's offer out from f, and nothing else: every check, every bump's version and whether it is offered, whether the release can start, the argv, and the sentence. Prepare runs it to show the sheet, and Start runs it again on fresh facts before anything runs.

type OriginReader

type OriginReader interface {
	Origin(ctx context.Context, dir string) (name repo.Name, onGitHub bool, err error)
}

OriginReader reads which GitHub repository a clone's origin is, and whether it is one. Core adapts localrepos.Inspect.

type Output

type Output struct {
	// Notes hold magex's WARN lines, as plain text, as Warnings, and the lines the reader
	// didn't recognize, each list with scriptrun's caps.
	scriptrun.Notes

	// Step is the last step magex reached, or "" before the first.
	Step Step `json:"step"`

	// Working is the step magex started and hasn't finished, or "": StepOnBranch while it
	// switches branches, StepUpdated while it pulls, and StepTagPushed while it sends the
	// tag. It stays set when magex stops partway, so it names where it stopped.
	Working Step `json:"working"`

	// Branch is the branch magex released from: the one it switched to, or found it was
	// already on.
	Branch string `json:"branch"`

	// Bump is the bump magex made: patch, minor, or major.
	Bump string `json:"bump"`

	// From and Version are the summary's From: and To: lines, the version magex worked
	// out from and the one it makes.
	From    string `json:"from"`
	Version string `json:"version"`

	// Tag is the tag magex made on this Mac, or "", and TagPushed reports that magex said
	// it reached origin.
	Tag       string `json:"tag"`
	TagPushed bool   `json:"tagPushed"`

	// PushSkipped reports magex's warning that origin couldn't be reached, so it skipped
	// sending the tag (magex 1.29.5 then exits 0; 1.30.0 and later fail, keeping the tag),
	// and PushSkipWarning is that warning.
	PushSkipped     bool   `json:"pushSkipped"`
	PushSkipWarning string `json:"pushSkipWarning"`

	// PushFailed reports magex's line saying the tag didn't reach origin.
	PushFailed bool `json:"pushFailed"`

	// BackOn is the branch magex said it switched back to, or "", and SwitchBackFailed
	// reports that it said it couldn't.
	BackOn           string `json:"backOn"`
	SwitchBackFailed bool   `json:"switchBackFailed"`

	// FastForward reports that magex updates the branch from origin by fast-forward only
	// (ff-only, magex 1.30.2), rather than with git pull --rebase, so stopping it while it
	// updates leaves no rebase behind.
	FastForward bool `json:"fastForward"`

	// DryRun reports magex's dry-run mode, which the app never asks for.
	DryRun bool `json:"dryRun"`

	// Canceled reports magex's line saying a signal stopped it.
	Canceled bool `json:"canceled"`

	// Errors are the messages of magex's ❌ Error: lines, the last maxOutputErrors, each
	// with the lines magex continues it on, joined by newlines.
	Errors []string `json:"errors"`

	// LoggedErrors are magex's ERROR and FATAL lines, as plain text: the first
	// scriptrun.MaxNotes.
	LoggedErrors []string `json:"loggedErrors"`

	// Signing is git's line saying it couldn't sign the tag, or "".
	Signing string `json:"signing"`

	// Auth is the line saying origin refused the git credentials, or "".
	Auth string `json:"auth"`

	// Refused is why origin refused the tag: the rule it broke, or the reason in git's
	// [remote rejected] line; "" when it refused nothing.
	Refused string `json:"refused"`

	// PushRejected reports one of git's ! [rejected] or ! [remote rejected] lines.
	PushRejected bool `json:"pushRejected"`

	// PushRefsFailed reports git's line saying the tag didn't go, and HookLine is the
	// last line that wasn't magex's or git's while magex sent it, before that line: a
	// pre-push hook's own, when one stopped it.
	PushRefsFailed bool   `json:"pushRefsFailed"`
	HookLine       string `json:"hookLine"`

	// Result is the JSON result of a run with json=true, or nil.
	Result *BumpResult `json:"result"`
}

Output is what a release's output said, as an OutputReader read it: a value that shares nothing with the reader, safe to keep while it goes on reading.

func (Output) LastError

func (o Output) LastError() string

LastError returns the first line of the last ❌ Error: line, or of the JSON result's error when there was none, or "".

func (Output) NotableWarnings

func (o Output) NotableWarnings() []string

NotableWarnings returns the warnings that tell the user something, for the result: every WARN line but those magex prints on every release with something to release. The log keeps them all, and Warnings still holds them for reading the failures.

type OutputReader

type OutputReader struct {
	// contains filtered or unexported fields
}

OutputReader reads magex version:bump's output as it arrives: an io.Writer for a run's Spec.Output, fed the log's bytes in order and split anywhere (scriptrun.LineWriter). It reads whole lines, ended by \r\n or \n, a bare \r overwriting the line as a terminal does, and color escapes removed. Snapshot returns what it has read, and is safe to call while it reads. The zero value is ready, as NewOutputReader's is.

A line it doesn't recognize leaves the step as it was and is kept for the result. It knows the lines of magex 1.29.5 and 1.30.2, recorded in testdata/magex-1.29.5 and testdata/magex-1.30.2, ff-only's among them, and the JSON result that json=true adds from 1.30.1.

func NewOutputReader

func NewOutputReader() *OutputReader

NewOutputReader returns a reader that has read nothing.

func (*OutputReader) Flush

func (r *OutputReader) Flush()

Flush reads the last line when the output ended without a newline. Call it once the output has ended.

func (*OutputReader) Lock

func (r *OutputReader) Lock()

Lock takes the lock no line is read without, so what the reader kept can be read.

func (*OutputReader) Progress

func (r *OutputReader) Progress(in Intent) scriptrun.Progress

Progress returns how far magex has got, as the reader has read its output so far, and whether the release may be stopped now: a release's scriptrun.Spec.Progress. in is what the release set out to do, as its Before completed it.

Stop is off from the moment magex starts switching to the branch it releases from until the pull ends, since SIGINT mid-pull leaves git's rebase in progress (S2's sigint-mid-rebase), and SIGINT mid-fast-forward can leave the branch's files partly updated. Once magex has made the tag, and until it has sent it, Stop asks first, since stopping can leave the tag on this Mac only; and while magex has the clone on another branch than the one it was on, Stop asks first too, since stopping leaves it there. A line magex prints is read within the runner's tail interval, so a Stop in that moment is judged on the line before it.

func (*OutputReader) Snapshot

func (r *OutputReader) Snapshot() Output

Snapshot returns what the reader has read so far. A line still missing its newline is read by Flush, not here.

func (*OutputReader) Unlock

func (r *OutputReader) Unlock()

Unlock lets the lock go.

func (*OutputReader) Write

func (r *OutputReader) Write(p []byte) (int, error)

Write reads p, the next part of the output. It never fails.

type Places

type Places interface {
	Where(ctx context.Context) (Where, error)
}

Places reads where runs go: the integrations.runsIn setting, and the terminal chosen for launches. Core adapts the settings.

type PrepareRequest

type PrepareRequest struct {
	// Repo is the repository, "owner/name", and Dir its clone as the Release page lists
	// it, with ~, or "" for the first clone of it found.
	Repo string `json:"repo"`
	Dir  string `json:"dir"`

	// Branch is the branch to release, or "" for the default on GitHub; Bump the bump, or
	// "" for patch.
	Branch string `json:"branch"`
	Bump   Bump   `json:"bump"`

	// Typed is what the user typed to confirm a major, and AllowModulePath the box ticked
	// to release a major go.mod doesn't name.
	Typed           string `json:"typed"`
	AllowModulePath bool   `json:"allowModulePath"`

	// RunsIn is where this release runs, or "" for the setting.
	RunsIn integrationprefs.RunsIn `json:"runsIn"`

	// Refresh reads GitHub, origin, and the clone again, as opening the sheet and Check
	// again do.
	Refresh bool `json:"refresh"`
}

PrepareRequest is what the sheet asks Prepare about: the repository and its clone, and the user's choice so far. Every choice is optional, and Decide reads them all, so a choice that changes what the sheet says is one more Prepare, served from the facts the sheet was last shown (FactsFor) unless Refresh is set.

type Refresher

type Refresher struct {
	// contains filtered or unexported fields
}

Refresher reads the Release page's list again behind the page, when the page was shown the list kept from a past start, and reads the repository each release ends in, or each review sheet merge goes into, again, patching its rows into the list (queuePatch, queueMerged). Meanwhile the list reads as refreshing, event.ReleasesProgress tells the page how far the read has got, and event.ReleasesUpdated when it lands. The desktop shell runs it as a worker, from start until quit; it is not bound. While it isn't running, a page shown the kept list waits for GitHub instead, and a release that ends puts the whole list out of date.

func NewRefresher

func NewRefresher(s *Service) *Refresher

NewRefresher returns the worker that reads s's list again behind the page.

func (*Refresher) Merged

func (r *Refresher) Merged(name repo.Name)

Merged tells the Refresher that a pull request merged into name in the review sheet, so it reads that repository's rows again while the list can be patched (queueMerged). It never waits. Core hands it to the review service.

func (*Refresher) RulesChanged

func (r *Refresher) RulesChanged()

RulesChanged tells the Release page that the user pinned or muted a repository or an org, or took its rule off. It never waits, and asks GitHub nothing: the window, told the list changed (event.ReleasesUpdated), asks for it again, and Candidates reads the rules as they are now, regrouping the list and reading alone a repository unmuted that was never read (liftMuted). Core calls it once the rules are stored.

func (*Refresher) Run

func (r *Refresher) Run(ctx context.Context)

Run reads the list again each time the page is shown the kept list, and the released repositories each time a release ends, until ctx ends, and returns once the read under way has. A read cut short by ctx keeps nothing, and a release it never read again leaves the list out of date, no longer refreshing, as one that ends while it isn't running does, and the window hears so (event.ReleasesUpdated).

type RepoFacts

type RepoFacts struct {
	// Name is the repository.
	Name repo.Name

	// Error says, as a sentence, why GitHub couldn't be read, or is "" when it was;
	// Found reports GitHub shows the repository to the user.
	Error string
	Found bool

	// Archived and Permission are its state and the user's access, as GitHub says.
	Archived   bool
	Permission string

	// DefaultBranch is its default branch, and HeadOID and Checks its newest commit and
	// that commit's checks, Failing those of them that failed.
	DefaultBranch string
	HeadOID       string
	Checks        Checks
	Failing       []FailedCheck

	// Branches are those of main and master that origin has (D10).
	Branches []string
}

RepoFacts is what GitHub says of the repository, and which of the branches Release offers besides the default origin has.

type RepoStatus

type RepoStatus struct {
	// Archived and Permission are the repository's state and the user's access to it.
	Archived   bool
	Permission string

	// DefaultBranch is the default branch, and HeadOID, HeadAt, Headline, and Checks its
	// newest commit: its ID, when it was committed, its headline, and its checks' rollup
	// state.
	DefaultBranch string
	HeadOID       string
	HeadAt        time.Time
	Headline      string
	Checks        Checks

	// Failing are the newest commit's checks that failed, in GitHub's order, which only
	// GitHub.RepoStatus reads; nil from ReleaseStatus.
	Failing []FailedCheck

	// Tags are the newest tags by commit date, each with the commit it points at.
	Tags []Tag
}

RepoStatus is what GitHub says about a repository, round one of the candidates: core adapts the client's answer to it.

type Result

type Result struct {
	// Kind is how it came out.
	Kind ResultKind `json:"kind"`

	// Version is the version the sheet showed, and Tag the one magex made, or set out to;
	// Moved reports they differ, as when a version was tagged meanwhile and magex, without
	// expect=, made the next one.
	Version string `json:"version"`
	Tag     string `json:"tag"`
	Moved   bool   `json:"moved"`

	// Commit is the commit the release's tag points at on origin, for ResultReleased. Head
	// is the commit the sheet showed, and Newer reports the release tagged another, a
	// commit that landed between the sheet and the run.
	Commit string `json:"commit"`
	Head   string `json:"head"`
	Newer  bool   `json:"newer"`

	// Taken reports origin has the tag at a commit this release didn't tag: someone else
	// released that version, and this release isn't on GitHub.
	Taken bool `json:"taken"`

	// Tagged reports the clone has the tag.
	Tagged bool `json:"tagged"`

	// Branch is the branch the clone is on now, "" when Detached or unknown; Original is
	// the one it was on when the sheet opened, and Back reports it is on that one again.
	// InProgress is what git is in the middle of there, as a rebase a stopped pull left.
	Branch     string            `json:"branch"`
	Detached   bool              `json:"detached"`
	Original   string            `json:"original"`
	Back       bool              `json:"back"`
	InProgress gitread.Operation `json:"inProgress"`

	// TagURL is the tag's page on GitHub, which shows the release once its workflow
	// publishes it, and WorkflowURL the repository's Actions runs for the tag; both are ""
	// unless it was released.
	TagURL      string `json:"tagUrl"`
	WorkflowURL string `json:"workflowUrl"`

	// PushWarning is magex's warning that it skipped the push, and Commands the commands
	// to finish or undo a tag origin doesn't have, quoted for a shell, which the app never
	// runs.
	PushWarning string   `json:"pushWarning"`
	Commands    []string `json:"commands"`

	// Failure names what stopped a release that isn't on GitHub, or is nil.
	Failure *Failure `json:"failure"`

	// Error says why origin couldn't be asked, for ResultUnverified.
	Error string `json:"error"`

	// Follow is how following the release's workflow on GitHub goes, once it was released
	// (Follower), or nil for a release that isn't followed.
	Follow *Follow `json:"follow"`
}

Result is a release's result for the window: its run's outcome detail (scriptrun.Result.Outcome), worked out from what magex said and what origin and the clone say once it ended, never from its exit status alone (§5.11.6).

type ResultKind

type ResultKind string

ResultKind is how a release came out, as the app verified it after magex ended.

const (
	// ResultReleased is a release origin has: its tag is on GitHub.
	ResultReleased ResultKind = "released"

	// ResultNotPushed is a tag made on this Mac that origin doesn't have: magex skipped
	// or failed the push, or GitHub refused the tag.
	ResultNotPushed ResultKind = "notPushed"

	// ResultFailed is a release that made no tag at all.
	ResultFailed ResultKind = "failed"

	// ResultUnverified is a release origin couldn't be asked about: it may be on GitHub.
	ResultUnverified ResultKind = "unverified"
)

The ways a release comes out.

type RuleSource

type RuleSource interface {
	RepoRules(ctx context.Context) (reporules.Rules, error)
}

RuleSource reads the repositories and orgs the user pinned or muted: core reads them from the prefs, which settings writes.

type RunHistory

type RunHistory interface {
	Run(ctx context.Context, id int64) (scriptrun.Run, error)
}

RunHistory reads a run back from the runner's history: the scriptrun Service.

type RunRecords

type RunRecords interface {
	Ended(ctx context.Context, kind scriptrun.Kind) ([]scriptrun.Record, error)
	Amend(ctx context.Context, id int64, change func(scriptrun.Record) (scriptrun.Amendment, bool)) (bool, error)
}

RunRecords reads the releases that ended, and rewrites how one came out as its follow goes: the scriptrun engine.

type Runs

type Runs interface {
	Start(ctx context.Context, spec scriptrun.Spec) (int64, error)
}

Runs starts a release's run: the scriptrun engine.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service lists what can be released, prepares a release's sheet, starts the release, reads a release's result back, and says whether a merge offers a release. The window binds it.

func NewService

func NewService(cfg Config) *Service

NewService returns a Service over cfg.

func (*Service) Candidates

func (s *Service) Candidates(ctx context.Context, refresh bool) (Candidates, error)

Candidates returns the repositories the Release page lists. It serves the last list, however old, while it is current and was read from the repository locations as set now, unless refresh is set: the whole list is read again only when the user asks (Read GitHub again), none was read yet, the locations changed, or the list went out of date (outOfDate). Otherwise it asks GitHub, in two rounds of batched queries, reads the unreleased clones' state, and emits event.ReleasesUpdated, telling the window how far it has got meanwhile (event.ReleasesProgress). A refresh that fails keeps the last list, with its error, until the user reads it again, and fails only when there is none.

After a restart, the list kept from the last start, when it was read from the repository locations as set now, is served at once, marked Kept and Refreshing, while the Refresher reads GitHub again behind the page; without the Refresher, the call waits for GitHub.

A release that ends, or a pull request merged in the review sheet, changes one repository's rows alone: while the Refresher runs, it reads that repository alone again and patches its rows into the list, which stays as current as it was (queuePatch, queueMerged). Meanwhile the list is served as it was, marked Refreshing. The rows whose newest commit's checks run are read again quietly, as often as the settings say, by the ChecksFollower (followChecks), which never marks the list Refreshing.

Every list is served under the pinned and muted repositories as they are now, read on each call: a muted repository is listed in GroupMuted, and GitHub is never asked about one muted as the list is read; a pinned one comes first in its group. Muting a listed repository asks nothing, and unmuting one that was never read reads it alone, as a release's patch does (liftMuted).

func (*Service) OfferAfterMerge

func (s *Service) OfferAfterMerge(ctx context.Context, owner, name, base string) (AfterMerge, error)

OfferAfterMerge answers whether the toast that reports a merge in the review sheet offers to release owner/name, whose pull request merged into base (§5.11.9). It offers when the integrations.offerAfterMerge setting is on, magex is usable, a clone in the repository locations has the repository as its GitHub origin, and base is a branch Release offers (D10): the repository's default branch, or main or master, which origin has, since the merge went into it. It reads only local state and what the app already knows, and asks GitHub nothing: the default branch comes from the Release page's last list, or else from what the inbox stored, and the clone from the page's list, or else from the folders named as the repository is, never a scan of every clone. It fails only for a repository that isn't one, or for local state it can't read; anything missing is no offer.

func (*Service) OpenTerminal

func (s *Service) OpenTerminal(ctx context.Context, repoText, dir string) error

OpenTerminal opens the terminal chosen for launches in the clone of repoText, the one the page shows at dir (with ~ for home), for a check's Open in terminal: the user commits, pushes, or deletes a tag there. The app runs nothing in it (scriptrun.OpenFolder). Only a clone the Release page lists, or the repository locations hold, with that GitHub origin, is opened.

func (*Service) Prepare

func (s *Service) Prepare(ctx context.Context, req PrepareRequest) (Offer, error)

Prepare gathers a release's facts and returns the offer Decide works out from them: the sheet's branches, checks, cards, and button. It finds the repository's clone among the Release page's clones, or by listing the repository locations. The facts are GitHub's (one query), origin's (one ls-remote), and the clone's (read-only git); a later Prepare for the same clone and branch within FactsFor decides again on them, with the new choice, unless req.Refresh is set. What can't be read is a check the offer shows, so it fails only for a request it can't serve.

func (*Service) ReleaseResult

func (s *Service) ReleaseResult(ctx context.Context, runID int64) (Result, error)

ReleaseResult returns a release's result, as its run recorded it once magex ended and the release was verified: the run's Result.Outcome, typed. The runner keeps a run's outcome as plain JSON, which the window can't name, so the window reads a release's here, and gets Result's own type. It fails for a run the history no longer holds (scriptrun.ErrNotFound), a run that isn't a release (ErrNotARelease), and a release with no result (ErrNoResult): one still going, or one that ended before magex did.

func (*Service) Start

func (s *Service) Start(ctx context.Context, req StartRequest) (int64, error)

Start starts the release the user chose on the sheet and returns its run's ID. The runner takes the clone's lock (a busy clone fails at once, naming what holds it) and a slot, and only then, in the run's Before, are the facts gathered again and decided on: the clone and origin read afresh, and GitHub's facts reused from the sheet while they are under FactsFor old, so a click asks GitHub nothing. magex's argv comes from that decision. The release starts only when the offer is ready and makes the version the button showed; otherwise the error says why, in words: ErrNotReady with the new reason, ErrVersionMoved with the new version, or ErrRejected, for what the sheet should never have sent. Once magex ends, the run's Finish verifies the release.

type SignFormat

type SignFormat string

SignFormat is how git signs a release's tag.

const (
	// SignNone is a tag git doesn't sign.
	SignNone SignFormat = ""

	// SignSSH signs with an ssh key: the ssh agent's, or a key file.
	SignSSH SignFormat = "ssh"

	// SignGPG signs with gpg, git's default format (openpgp).
	SignGPG SignFormat = "openpgp"

	// SignX509 signs with an X.509 certificate, through gpgsm.
	SignX509 SignFormat = "x509"
)

The ways git signs a tag.

type SigningFacts

type SigningFacts struct {
	Format SignFormat

	// AgentHasKey reports, for ssh, that the ssh agent holds the signing key, and OpenKey
	// that the key's file opens without a passphrase.
	AgentHasKey bool
	OpenKey     bool

	// WindowPinentry reports, for gpg, that gpg-agent's pinentry asks in a window.
	WindowPinentry bool
}

SigningFacts says whether git signs a release's tag here, how, and whether it can do it without asking in a terminal.

type StartRequest

type StartRequest struct {
	// Repo is the repository, "owner/name", and Dir its clone, as in PrepareRequest.
	Repo string `json:"repo"`
	Dir  string `json:"dir"`

	// Branch is the branch to release, or "" for the default on GitHub, and Bump the bump.
	Branch string `json:"branch"`
	Bump   Bump   `json:"bump"`

	// Version is the version the button showed (Offer.Version), Head the commit the sheet
	// showed (Offer.Head), and Original the branch the clone was on (Offer.Current).
	Version  string `json:"version"`
	Head     string `json:"head"`
	Original string `json:"original"`

	// Typed and AllowModulePath confirm a major, as in PrepareRequest.
	Typed           string `json:"typed"`
	AllowModulePath bool   `json:"allowModulePath"`

	// RunsIn is where this release runs, or "" for the setting.
	RunsIn integrationprefs.RunsIn `json:"runsIn"`
}

StartRequest is the release the user started on the sheet: the choice, and what the sheet showed when they clicked, which Start holds the fresh facts to.

type Step

type Step string

Step is a step of a release, as the sheet lists them. The names avoid git's own verbs, which the repository guards ban as string literals.

const (
	// StepOnBranch is magex on the branch it releases from: switched to it, or already
	// on it.
	StepOnBranch Step = "onBranch"

	// StepUpdated is the branch brought up to date with origin.
	StepUpdated Step = "updated"

	// StepTagCreated is the version tag made on this Mac.
	StepTagCreated Step = "tagCreated"

	// StepTagPushed is the tag sent to origin, as magex tells it.
	StepTagPushed Step = "tagPushed"

	// StepVerified is the tag found on origin by the app itself, after magex ends. The
	// output reader never sets it.
	StepVerified Step = "verified"
)

The steps of a release, in order.

func (Step) Reached

func (s Step) Reached(step Step) bool

Reached reports whether s is step or a later one.

type Tag

type Tag struct {
	Name   string
	Commit string
}

Tag is a tag and the commit it points at, peeled through an annotated tag.

type TagRun

type TagRun struct {
	// Workflow is its workflow's name, as goreleaser, and URL its page.
	Workflow string
	URL      string

	// Done reports it ended, and Failed that it failed, timed out, or never started.
	Done   bool
	Failed bool
}

TagRun is one of the tag's own workflow runs.

type ToolFacts

type ToolFacts struct {
	integrations.CopyFacts

	// MinVersion is the oldest version Release drives, and ExpectSince the first release
	// with expect=, or "" while none has it.
	MinVersion  string
	ExpectSince string
}

ToolFacts is what Release knows of magex: the copy in use, where it is, its version, and what it can do (integrations.CopyFacts), and the versions Release goes by.

func ToolFactsOf

func ToolFactsOf(def integrations.Definition, tool integrations.Tool) ToolFacts

ToolFactsOf reads magex's facts from the integrations' view of it: def is mage-x's definition and tool what the settings show of it.

type ToolSource

type ToolSource interface {
	ReleaseTool(ctx context.Context) ToolFacts
}

ToolSource reads what Release knows of magex. Core adapts the integrations service, with ToolFactsOf. It never fails: a magex it can't read is missing.

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier verifies the releases from before the app restarted (scriptrun.Verifier): a release orphaned, still running, or interrupted gets an output reader and a Finish again, built from its record's intent, so it is read and verified as a release the app started is. Core registers it with the runner for scriptrun.KindRelease. It is its own type, not a method of the Service, which the window binds.

func NewVerifier

func NewVerifier(s *Service) Verifier

NewVerifier returns the Verifier of s's releases.

func (Verifier) Verify

Verify gives a release from before the app restarted its reader, its progress, its Recorded, and its Finish, which first waits for the login shell's environment (Config.Ready). A record whose intent can't be read, or a Service that can't read git, gets none: the runner's own outcome stands.

type Version

type Version struct {
	Major, Minor, Patch int
}

Version is a release version, vMajor.Minor.Patch. A prerelease tag reads as the release it leads to, as magex reads it: v1.5.0-rc.1 is v1.5.0 here.

func Highest

func Highest(tags []string) (Version, bool)

Highest returns the highest version among tags, by number, and whether there was one. Every version tag counts, on any commit, reachable or not, as magex counts them.

func Next

func Next(tags []string, b Bump) Version

Next returns the version magex makes for b over tags: the highest version raised by b, or b over v0.0.0 when there is none. It matches magex's own choice, recorded from magex 1.29.5 and 1.30.2 in testdata/magex-*/next-version.json. A raised highest version is above every tag, so no tag ever names it already: magex's skip of a taken version never comes into it.

func ParseVersion

func ParseVersion(tag string) (Version, bool)

ParseVersion reads a tag as magex does, and reports whether it is a version at all.

func (Version) Bumped

func (v Version) Bumped(b Bump) Version

Bumped returns v raised by b.

func (Version) Less

func (v Version) Less(w Version) bool

Less reports whether v comes before w, by number: v1.4.2 comes before v1.4.10.

func (Version) String

func (v Version) String() string

String returns the version as a tag: v1.4.3.

type Where

type Where struct {
	RunsIn   integrationprefs.RunsIn
	Terminal string
}

Where is where runs go, as the user set it: in the app or in the terminal, and, for a run there, the terminal's name, as in "iTerm2".

type Workflow

type Workflow struct {
	// Published reports the release published, and ReleaseURL is its page.
	Published  bool
	ReleaseURL string

	// Runs are the tag's own workflow runs: those a push of the tag started at its commit.
	// They are left unread once the release is published.
	Runs []TagRun
}

Workflow is how a release's workflow on GitHub goes, as one poll read it.

type Workflows

type Workflows interface {
	ReleaseWorkflow(ctx context.Context, name repo.Name, tag, commit string) (Workflow, error)
}

Workflows reads how a release's workflow goes on GitHub: core adapts the GitHub client's FetchReleaseProgress, which the API budget counts. commit is the commit the release's tag points at on origin.

Jump to

Keyboard shortcuts

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