Documentation
¶
Overview ¶
Package update replaces the running git-stack binary with the latest GitHub release.
It talks plain HTTPS to the GitHub releases API and the release assets, so it works without gh being logged in. Assets are the archives goreleaser publishes (git-stack_<ver>_<os>_<arch>.tar.gz plus checksums.txt); the archive is verified against checksums.txt before anything is written.
Index ¶
Constants ¶
const ( // DefaultCheckTTL is how long one check is trusted before the next // command asks GitHub again. DefaultCheckTTL = 24 * time.Hour // DefaultCheckTimeout bounds one background request; a slow network // must never hold a command up. DefaultCheckTimeout = 5 * time.Second )
Defaults for Checker.
const DefaultRepo = "DomBlack/git-stack"
DefaultRepo is the GitHub repository releases are published from.
Variables ¶
This section is empty.
Functions ¶
func DefaultCacheDir ¶ added in v0.1.5
DefaultCacheDir is where the user wide cache lives: the OS cache directory (XDG_CACHE_HOME or ~/.cache on Linux, ~/Library/Caches on macOS) plus git-stack.
Types ¶
type Check ¶ added in v0.1.5
type Check struct {
// Current is the running binary.
Current version.Info
// contains filtered or unexported fields
}
Check is one run's view of the latest release.
func (*Check) Available ¶ added in v0.1.5
Available reports the newer release worth mentioning, if there is one: this run's answer when it has already arrived, otherwise the previous run's. Dev builds are left alone (they were built that way on purpose, and update would not replace them anyway), as are binaries ahead of the latest release.
type Checker ¶ added in v0.1.5
type Checker struct {
Client *Client
Store *cache.Store
TTL time.Duration // zero: DefaultCheckTTL
Timeout time.Duration // zero: DefaultCheckTimeout
}
Checker keeps the latest release up to date in the background. Start returns straight away with whatever the last run found; when that is older than TTL it asks GitHub once more in a goroutine and records the answer for the next run. A command never waits for it.
type Client ¶
type Client struct {
HTTP *http.Client
BaseURL string // GitHub API base, https://api.github.com
Repo string // owner/name
UserAgent string
}
Client fetches releases. The zero value is not usable; use New.
type Known ¶ added in v0.1.5
type Known struct {
Latest string `json:"latest"`
}
Known is what the background check remembers between runs.
type Options ¶
type Options struct {
// Current is the running binary's version.
Current version.Info
// Target is the file to replace, normally os.Executable with symlinks resolved.
Target string
// GOOS and GOARCH pick the asset.
GOOS, GOARCH string
// Check only reports; nothing is downloaded.
Check bool
// Force replaces the binary even when it is up to date, ahead, or a dev build.
Force bool
}
Options control Run.
type Result ¶
type Result struct {
Status Status
Current string
Latest string
// DevBuild is true when the running binary is not a release.
DevBuild bool
Target string
}
Result reports the outcome of Run.
type Status ¶
type Status int
Status says what Run did.
const ( // StatusUpToDate: the binary already is the latest release. StatusUpToDate Status = iota // StatusAhead: the binary is newer than the latest release. StatusAhead // StatusAvailable: a release is available but nothing was changed (Check, // or a dev build without Force). StatusAvailable // StatusUpdated: the binary was replaced. StatusUpdated )