Documentation
¶
Overview ¶
Package github queries GitHub through the user's gh authentication.
Index ¶
- Constants
- func IsClientError(err error) bool
- func ParsePRRef(s string) (string, int, error)
- type Client
- func (c *Client) Approve(ctx context.Context, repo string, number int, commitID, body string) error
- func (c *Client) GetPR(ctx context.Context, repo string, number int) (PRDetail, error)
- func (c *Client) HasReview(ctx context.Context, repo string, number int, marker string) (bool, error)
- func (c *Client) PostReview(ctx context.Context, repo string, number int, p ReviewPost) (PostResult, error)
- func (c *Client) SearchPRs(ctx context.Context, query string) ([]PR, error)
- func (c *Client) WithREST(r REST) *Client
- type GraphQL
- type PR
- type PRDetail
- type PartialError
- type PostResult
- type REST
- type ReviewComment
- type ReviewPost
Constants ¶
const SearchLimit = 50
SearchLimit is the maximum number of PRs returned per view query.
Variables ¶
This section is empty.
Functions ¶
func IsClientError ¶
IsClientError reports a definite 4xx rejection: the request did not take effect. Anything else (5xx, timeout, network) may have reached GitHub.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewDefault ¶
NewDefault builds a Client from the user's gh auth configuration.
func (*Client) Approve ¶
Approve submits an APPROVE review on commitID. Unlike PostReview it never falls back: if GitHub refuses (for example, your own pull request), the approval simply failed.
func (*Client) HasReview ¶
func (c *Client) HasReview(ctx context.Context, repo string, number int, marker string) (bool, error)
HasReview reports whether any of the PR's reviews contains marker. Ghost uses it to avoid re-posting a review or approval whose request timed out, so it reads every page (reviews are listed oldest first).
func (*Client) PostReview ¶
func (c *Client) PostReview(ctx context.Context, repo string, number int, p ReviewPost) (PostResult, error)
PostReview submits a review. GitHub answers 422 both when you request changes on (or approve) your own PR and when an inline comment is outside the diff. For the own-PR case it retries as a plain COMMENT, keeping the inline comments; for other 422s it retries with the comments folded into the body, then, if needed, as a COMMENT.
type GraphQL ¶
type GraphQL interface {
DoWithContext(ctx context.Context, query string, variables map[string]interface{}, response interface{}) error
}
GraphQL is the subset of go-gh's GraphQLClient that Client uses.
type PR ¶
type PartialError ¶
PartialError reports PRs a search matched but GitHub would not return, for example PRs in organizations that enforce SAML for the user's token.
func (*PartialError) Error ¶
func (e *PartialError) Error() string
type PostResult ¶
type PostResult struct {
Folded bool // inline comments moved into the body
Downgraded bool // event changed to COMMENT
}
PostResult says which fallbacks PostReview needed.
type REST ¶
type REST interface {
DoWithContext(ctx context.Context, method, path string, body io.Reader, response interface{}) error
}
REST is the subset of go-gh's RESTClient that Client uses.
type ReviewComment ¶
type ReviewPost ¶
type ReviewPost struct {
CommitID string `json:"commit_id"`
Event string `json:"event"` // COMMENT, REQUEST_CHANGES or APPROVE
Body string `json:"body"`
Comments []ReviewComment `json:"comments,omitempty"`
}