Documentation
¶
Overview ¶
Package github is a minimal GitHub REST client scoped to what whodar ingests: repositories, contributors, pull requests, CODEOWNERS, and users. The token is held only in memory, never serialized, and never logged.
Index ¶
- Variables
- type Account
- type Client
- func (c *Client) Account(ctx context.Context, login string) (Account, error)
- func (c *Client) Contributors(ctx context.Context, owner, repo string) ([]Contributor, error)
- func (c *Client) FileContents(ctx context.Context, owner, repo, path string) ([]byte, error)
- func (c *Client) Issues(ctx context.Context, owner, repo string) ([]Issue, error)
- func (c *Client) OrgRepos(ctx context.Context, org string) ([]Repo, error)
- func (c *Client) PullRequests(ctx context.Context, owner, repo string) ([]PullRequest, error)
- func (c *Client) Repo(ctx context.Context, owner, repo string) (Repo, error)
- type Contributor
- type Doer
- type Issue
- type Option
- type PullRequest
- type Repo
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("github: not found")
ErrNotFound indicates the requested resource does not exist.
var ErrRateLimited = errors.New("github: rate limited")
ErrRateLimited indicates the API rate limit was exhausted.
var ErrStatus = errors.New("github: unexpected status")
ErrStatus indicates an unexpected HTTP status.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// Login is the user's handle.
Login string `json:"login"`
// Name is the user's display name.
Name string `json:"name"`
// Email is the user's public email, often empty.
Email string `json:"email"`
}
Account is a user's public profile subset.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the GitHub REST API.
func New ¶
New returns a Client for token. It panics on an empty token; callers validate token presence before constructing the client.
func (*Client) Contributors ¶
Contributors returns up to 100 contributors, most commits first.
func (*Client) FileContents ¶
FileContents returns the decoded contents of a file, or ErrNotFound if it is absent.
func (*Client) Issues ¶
Issues returns up to 100 recently updated issues of any state. The result includes pull requests, which the caller can filter with IsPullRequest.
func (*Client) PullRequests ¶
PullRequests returns up to 100 recently updated pull requests of any state.
type Contributor ¶
type Contributor struct {
// Login is the contributor's handle.
Login string `json:"login"`
// Contributions is the contributor's commit count.
Contributions int `json:"contributions"`
}
Contributor is a repository contributor.
type Doer ¶
type Doer interface {
// Do performs the request and returns the response.
Do(req *http.Request) (*http.Response, error)
}
Doer performs an HTTP request. *http.Client satisfies it; tests inject a stub.
type Issue ¶
type Issue struct {
// Title is the issue title.
Title string `json:"title"`
// User is the author.
User account `json:"user"`
// Assignees are users assigned to the issue.
Assignees []account `json:"assignees"`
// Labels are the applied labels.
Labels []label `json:"labels"`
// PullRequest is present when the issue is actually a pull request.
PullRequest json.RawMessage `json:"pull_request"`
// UpdatedAt is when the issue last changed.
UpdatedAt time.Time `json:"updated_at"`
}
Issue is the subset of an issue whodar reads. The GitHub issues endpoint also returns pull requests; IsPullRequest distinguishes them.
func (Issue) AssigneeLogins ¶
AssigneeLogins returns the assignees' logins.
func (Issue) IsPullRequest ¶
IsPullRequest reports whether this issue is really a pull request.
type PullRequest ¶
type PullRequest struct {
// Title is the pull request title.
Title string `json:"title"`
// User is the author.
User account `json:"user"`
// Labels are the applied labels.
Labels []label `json:"labels"`
// RequestedReviewers are users asked to review.
RequestedReviewers []account `json:"requested_reviewers"`
// Assignees are users assigned to the pull request.
Assignees []account `json:"assignees"`
// UpdatedAt is when the pull request last changed.
UpdatedAt time.Time `json:"updated_at"`
}
PullRequest is the subset of a pull request whodar reads.
func (PullRequest) AssigneeLogins ¶
func (p PullRequest) AssigneeLogins() []string
AssigneeLogins returns the assignees' logins.
func (PullRequest) Author ¶
func (p PullRequest) Author() string
Author returns the pull request author's login.
func (PullRequest) LabelNames ¶
func (p PullRequest) LabelNames() []string
LabelNames returns the label names.
func (PullRequest) Reviewers ¶
func (p PullRequest) Reviewers() []string
Reviewers returns the requested reviewers' logins.
type Repo ¶
type Repo struct {
// Name is the repository name.
Name string `json:"name"`
// FullName is the owner/name path.
FullName string `json:"full_name"`
// Description is the repository description.
Description string `json:"description"`
// Topics are the repository's topic tags.
Topics []string `json:"topics"`
}
Repo is a repository's indexable metadata.