Documentation
¶
Overview ¶
Package github is loupe's narrow view of the GitHub REST API, behind an interface so tests can fake it.
Index ¶
- type Client
- type Commit
- type ComparedFile
- type Comparison
- type HTTPError
- type PullRequest
- type REST
- func (c *REST) Compare(ctx context.Context, owner, repo, base, head string) (Comparison, error)
- func (c *REST) CreateReview(ctx context.Context, owner, repo string, number int, req ReviewRequest) (Review, error)
- func (c *REST) ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error)
- func (c *REST) PullRequest(ctx context.Context, owner, repo string, number int) (PullRequest, error)
- func (c *REST) PullRequestsForBranch(ctx context.Context, owner, repo, headOwner, branch string) ([]PullRequest, error)
- func (c *REST) Viewer(ctx context.Context) (string, error)
- type Review
- type ReviewComment
- type ReviewRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
PullRequest(ctx context.Context, owner, repo string, number int) (PullRequest, error)
PullRequestsForBranch(ctx context.Context, owner, repo, headOwner, branch string) ([]PullRequest, error)
Viewer(ctx context.Context) (string, error)
ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error)
CreateReview(ctx context.Context, owner, repo string, number int, req ReviewRequest) (Review, error)
Compare(ctx context.Context, owner, repo, base, head string) (Comparison, error)
}
type ComparedFile ¶
type Comparison ¶
type Comparison struct {
Status string
AheadBy int
Commits []Commit
// Files stops at GitHub's cap of 300 files.
Files []ComparedFile
}
Comparison is what head adds to base. Status is GitHub's: ahead only when base is an ancestor of head.
type HTTPError ¶
HTTPError is a response GitHub actually sent. Anything else (transport failure, timeout) leaves the outcome of a write unknown.
type PullRequest ¶
type PullRequest struct {
Number int
URL string
Title string
State string
Author string
BaseRef string
BaseSHA string
HeadSHA string
// HeadOwner and HeadRepo name the repository the head lives in, a fork for a cross-repository pull request. Both are
// empty once that fork is deleted.
HeadOwner string
HeadRepo string
}
type REST ¶
type REST struct {
// contains filtered or unexported fields
}
func NewREST ¶
func NewREST(transport http.RoundTripper) (*REST, error)
NewREST uses gh's stored token for github.com. A nil transport means the default.
func NewRESTWithToken ¶
func NewRESTWithToken(transport http.RoundTripper, token string) (*REST, error)
NewRESTWithToken skips gh's token lookup so tests never read the developer's credentials.
func (*REST) CreateReview ¶
func (*REST) ListReviews ¶
func (*REST) PullRequest ¶
func (*REST) PullRequestsForBranch ¶
type ReviewComment ¶
type ReviewRequest ¶
type ReviewRequest struct {
CommitID string `json:"commit_id"`
Body string `json:"body"`
Event string `json:"event"`
Comments []ReviewComment `json:"comments,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.