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 IssueComment
- 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) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
- func (c *REST) ListReviewThreads(ctx context.Context, owner, repo string, number int) ([]ReviewThread, 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) PullRequestCommits(ctx context.Context, owner, repo string, number int) ([]Commit, error)
- func (c *REST) PullRequestsForBranch(ctx context.Context, owner, repo, headOwner, branch string) ([]PullRequest, error)
- func (c *REST) TokenKind() TokenKind
- func (c *REST) UpdateReview(ctx context.Context, owner, repo string, number int, id int64, body string) (Review, error)
- func (c *REST) Viewer(ctx context.Context) (string, error)
- type Review
- type ReviewComment
- type ReviewRequest
- type ReviewThread
- type ThreadComment
- type TokenKind
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)
// ListReviewThreads reads every inline thread with its comments, since only GraphQL carries a thread's resolved state.
ListReviewThreads(ctx context.Context, owner, repo string, number int) ([]ReviewThread, error)
ListIssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
CreateReview(ctx context.Context, owner, repo string, number int, req ReviewRequest) (Review, error)
// UpdateReview replaces a submitted review's body, and nothing else about it.
UpdateReview(ctx context.Context, owner, repo string, number int, id int64, body string) (Review, error)
// PullRequestCommits lists the pull request's commits, which loupe assumes are oldest first, since GitHub documents
// no order. GitHub stops at 250.
PullRequestCommits(ctx context.Context, owner, repo string, number int) ([]Commit, error)
Compare(ctx context.Context, owner, repo, base, head string) (Comparison, error)
TokenKind() TokenKind
}
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 IssueComment ¶ added in v0.13.0
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) ListIssueComments ¶ added in v0.13.0
func (*REST) ListReviewThreads ¶ added in v0.13.0
func (*REST) ListReviews ¶
func (*REST) PullRequest ¶
func (*REST) PullRequestCommits ¶ added in v0.15.0
func (*REST) PullRequestsForBranch ¶
func (*REST) UpdateReview ¶ added in v0.11.0
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"`
}
type ReviewThread ¶ added in v0.13.0
type ReviewThread struct {
Path string
Line int
OriginalLine int
Side string
Resolved bool
Outdated bool
Comments []ThreadComment
}
ReviewThread is one inline conversation. Line is 0 when the thread is outdated or on a whole file, and OriginalLine is the line it was left on.
type ThreadComment ¶ added in v0.13.0
ThreadComment's ReviewID is the REST id of the review that posted it, 0 when GitHub names none.