Documentation
¶
Overview ¶
Package github provides HTTP client functionality for the GitHub API.
Index ¶
- func FetchFileTree(ctx context.Context, client *Client, owner, repo, branch string) string
- func FetchOwnedRepos(ctx context.Context, client *Client) (<-chan Repo, <-chan error)
- func FetchReadme(ctx context.Context, client *Client, owner, repo string) string
- func FetchStarredRepos(ctx context.Context, client *Client) (<-chan Repo, <-chan error)
- func ResetDefaultBaseURL()
- func SetDefaultBaseURL(url string)
- type Client
- type Owner
- type PATValidationResult
- type RateLimitError
- type RateLimitInfo
- type Repo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchFileTree ¶
FetchFileTree fetches the git tree for the given repo and branch. Returns only blob entries at depth <= 2 (paths with at most one '/'), sorted alphabetically, joined by newlines. Returns "" on any error — never returns an error.
func FetchOwnedRepos ¶
FetchOwnedRepos returns a channel that yields owned repos one at a time. Pagination is handled internally. The channel is closed when all pages are exhausted or an error occurs. Errors are sent on the errCh channel.
func FetchReadme ¶
FetchReadme fetches and base64-decodes the README for the given repo. Returns ("", nil) if the repo has no README (404). Never returns an error — logs and returns empty string on any failure.
func FetchStarredRepos ¶
FetchStarredRepos returns a channel that yields starred repos one at a time.
func ResetDefaultBaseURL ¶
func ResetDefaultBaseURL()
ResetDefaultBaseURL resets the default base URL to the original value.
func SetDefaultBaseURL ¶
func SetDefaultBaseURL(url string)
SetDefaultBaseURL sets the default base URL for new clients (for testing).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client for the GitHub API.
type PATValidationResult ¶
PATValidationResult contains the result of validating a GitHub PAT.
func ValidatePAT ¶
func ValidatePAT(ctx context.Context, client *Client) PATValidationResult
ValidatePAT calls GET /user and checks the x-oauth-scopes header. Returns a result even on failure — never returns an error directly.
type RateLimitError ¶
RateLimitError is returned when the GitHub API rate limit is exceeded and the retry also failed.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type RateLimitInfo ¶
type RateLimitInfo struct {
Limit int
Remaining int
ResetAt string // ISO datetime string
Available bool
}
RateLimitInfo contains GitHub API rate limit information.
func GetRateLimitInfo ¶
func GetRateLimitInfo(ctx context.Context, client *Client) *RateLimitInfo
GetRateLimitInfo fetches the current rate limit status. Returns nil on any error.
type Repo ¶
type Repo struct {
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description *string `json:"description"`
Private bool `json:"private"`
Owner Owner `json:"owner"`
HTMLURL string `json:"html_url"`
CloneURL string `json:"clone_url"`
Language *string `json:"language"`
StargazersCount int `json:"stargazers_count"`
ForksCount int `json:"forks_count"`
DefaultBranch string `json:"default_branch"`
Topics []string `json:"topics"`
PushedAt string `json:"pushed_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Archived bool `json:"archived"`
Fork bool `json:"fork"`
Size int `json:"size"`
}
Repo represents a GitHub repository from the API.