Documentation
¶
Index ¶
- Constants
- func IsNewer(a, b string) bool
- func NewCmdUpdate(f *cmdutil.Factory, version string) *cobra.Command
- func ParseVersion(v string) [3]int
- func PrintNotice(w io.Writer, currentVersion string, result *CheckResult)
- func ShouldCheck(version string, args []string) bool
- type CheckResult
- type GithubAsset
- type GithubRelease
Constants ¶
const ( RepoOwner = "aarondpn" RepoName = "redmine-cli" ReleaseURL = "https://api.github.com/repos/" + RepoOwner + "/" + RepoName + "/releases/latest" )
Variables ¶
This section is empty.
Functions ¶
func IsNewer ¶
IsNewer returns true if version a is newer than version b. Versions are expected as "major.minor.patch" (no "v" prefix).
func NewCmdUpdate ¶
NewCmdUpdate creates the update command.
func ParseVersion ¶
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 ¶
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.