github

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidGitHubURL indicates the GitHub URL format is invalid.
	ErrInvalidGitHubURL = errors.New("invalid GitHub URL")

	// ErrUnsupportedGitHubHost indicates the GitHub host is not supported.
	ErrUnsupportedGitHubHost = errors.New("unsupported GitHub host")

	// ErrNoVersionsFound indicates no versions were found for a repository.
	ErrNoVersionsFound = errors.New("no versions found")
)

Error definitions for the github package.

View Source
var RateLimitWaiter = waitForRateLimitImpl

RateLimitWaiter is the function used to wait for rate limits. Tests can override this to skip the actual wait.

Functions

func ConvertToRawURL added in v1.203.0

func ConvertToRawURL(githubURL string) (string, error)

ConvertToRawURL converts a GitHub repository URL to its raw content URL. Supports various GitHub URL formats and converts them to raw.githubusercontent.com URLs.

Examples:

func GetLatestRelease

func GetLatestRelease(owner string, repo string) (string, error)

GetLatestRelease returns the latest release tag for a GitHub repository.

func GetLatestReleaseInfo

func GetLatestReleaseInfo(owner, repo string) (*github.RepositoryRelease, error)

GetLatestReleaseInfo fetches the latest stable release from GitHub.

func GetReleaseByTag

func GetReleaseByTag(owner, repo, tag string) (*github.RepositoryRelease, error)

GetReleaseByTag fetches a specific GitHub release by tag name.

func GetReleaseVersions added in v1.203.0

func GetReleaseVersions(owner, repo string, limit int) ([]string, error)

GetReleaseVersions fetches release versions as strings (tag names without 'v' prefix). Returns only non-prerelease versions, suitable for toolchain version management.

func GetReleases

func GetReleases(opts ReleasesOptions) ([]*github.RepositoryRelease, error)

GetReleases fetches GitHub releases with pagination, prerelease filtering, and date filtering.

func ShouldWaitForRateLimit added in v1.203.0

func ShouldWaitForRateLimit(ctx context.Context, minRemaining int) bool

ShouldWaitForRateLimit checks if rate limit is low enough to warrant waiting. This is a non-blocking check that just returns the decision.

func ShouldWaitForRateLimitWithService added in v1.203.0

func ShouldWaitForRateLimitWithService(ctx context.Context, service RateLimitService, minRemaining int) bool

ShouldWaitForRateLimitWithService checks if rate limit is low using a custom service. This is primarily used for testing with mock services.

func WaitForRateLimit added in v1.203.0

func WaitForRateLimit(ctx context.Context, minRemaining int) error

WaitForRateLimit checks GitHub rate limits and waits if necessary. If remaining requests are below minRemaining, it waits until the rate limit resets. Uses a spinner UI in TTY mode, otherwise simple output. Returns nil on success or context cancellation error. Does not return error on rate limit check failures (to avoid blocking operations).

Types

type RateLimitService added in v1.203.0

type RateLimitService interface {
	Get(ctx context.Context) (*github.RateLimits, *github.Response, error)
}

RateLimitService defines the interface for rate limit operations. This allows for mocking in tests.

type RateLimitStatus added in v1.203.0

type RateLimitStatus struct {
	// Remaining is the number of requests remaining in the current rate limit window.
	Remaining int
	// Limit is the maximum number of requests allowed in the rate limit window.
	Limit int
	// ResetAt is when the rate limit will reset.
	ResetAt time.Time
}

RateLimitStatus contains information about GitHub API rate limits.

func CheckRateLimit added in v1.203.0

func CheckRateLimit(ctx context.Context) (*RateLimitStatus, error)

CheckRateLimit queries the GitHub API for current rate limit status. Returns nil status (not error) if the check fails, to avoid blocking operations.

func CheckRateLimitWithService added in v1.203.0

func CheckRateLimitWithService(ctx context.Context, service RateLimitService) (*RateLimitStatus, error)

CheckRateLimitWithService queries the GitHub API using a custom service. This is primarily used for testing with mock services.

type ReleasesOptions

type ReleasesOptions struct {
	Owner              string
	Repo               string
	Limit              int
	Offset             int
	IncludePrereleases bool
	Since              *time.Time
}

ReleasesOptions contains options for fetching GitHub releases.

Jump to

Keyboard shortcuts

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