update

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RepoOwner = "aarondpn"
	RepoName  = "redmine-cli"

	ReleaseURL = "https://api.github.com/repos/" + RepoOwner + "/" + RepoName + "/releases/latest"
)

Variables

This section is empty.

Functions

func IsNewer

func IsNewer(a, b string) bool

IsNewer returns true if version a is newer than version b. Versions are expected as "major.minor.patch" (no "v" prefix).

func NewCmdUpdate

func NewCmdUpdate(f *cmdutil.Factory, version string) *cobra.Command

NewCmdUpdate creates the update command.

func ParseVersion

func ParseVersion(v string) [3]int

ParseVersion parses a semver string into [major, minor, patch].

func PrintNotice

func PrintNotice(w io.Writer, currentVersion string, result *CheckResult)

PrintNotice writes an update notice to w.

func ShouldCheck

func ShouldCheck(version string, args []string) bool

ShouldCheck returns true if the background update check should run.

Types

type CheckResult

type CheckResult struct {
	NewVersion string // e.g. "1.3.0" (without "v" prefix)
	ReleaseURL string // full GitHub release page URL
}

CheckResult holds the outcome of a background update check.

func CheckForUpdate

func CheckForUpdate(ctx context.Context, currentVersion string) *CheckResult

CheckForUpdate checks GitHub for a newer release. It returns nil on any error or if the current version is already up to date.

func CheckForUpdateCached

func CheckForUpdateCached(ctx context.Context, currentVersion string) *CheckResult

CheckForUpdateCached checks GitHub for a newer release, caching the result for 24 hours. Cache is version-aware: entries from a different binary version are ignored.

Failure semantics (Option B): Only successful checks are cached. A "successful check" means the GitHub API responded. The result may indicate no update is available (update_available=false) or an update is available (update_available=true, with version fields). Network errors and timeouts are NOT cached, so a retry happens on the next invocation.

Cached positive results are defensively revalidated with IsNewer before being returned, ensuring stale cache entries (e.g. after a GitHub release rollback) do not surface a false upgrade notice.

type GithubAsset

type GithubAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

GithubAsset represents a release asset.

type GithubRelease

type GithubRelease struct {
	TagName string        `json:"tag_name"`
	Assets  []GithubAsset `json:"assets"`
}

GithubRelease represents a GitHub release.

func FetchLatestRelease

func FetchLatestRelease(ctx context.Context) (*GithubRelease, error)

FetchLatestRelease fetches the latest release from GitHub.

Jump to

Keyboard shortcuts

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