github

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package github is the CodeHost adapter for github.com: REST reads with ETag conditional requests cached in the Cache port, and GraphQL for review state and writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the GitHub REST and GraphQL APIs.

func New

func New(httpClient *http.Client, baseURL string, c cache.Cache) *Client

New returns a Client for the API at baseURL (e.g. https://api.github.com) whose HTTP client handles authentication.

func NewFromGH

func NewFromGH(c cache.Cache, wrap func(http.RoundTripper) http.RoundTripper) (*Client, error)

NewFromGH returns a Client for api.github.com authenticated through `gh auth`. wrap, if given, wraps its HTTP transport, e.g. to count requests.

func (*Client) AddConversationComment

func (c *Client) AddConversationComment(ctx context.Context, prID, body string) error

func (*Client) AddThread

func (c *Client) AddThread(ctx context.Context, reviewID string, t codehost.NewThread) error

func (*Client) Checks

func (c *Client) Checks(ctx context.Context, ref domain.PRRef) (domain.Checks, error)

func (*Client) Commits

func (c *Client) Commits(ctx context.Context, ref domain.PRRef) ([]domain.Commit, error)

func (*Client) Dashboard

func (c *Client) Dashboard(ctx context.Context) (codehost.Dashboard, error)

Dashboard runs its two searches at once: GitHub's search API takes seconds per query and sends no ETag to revalidate with.

func (*Client) DeleteConversationComment

func (c *Client) DeleteConversationComment(ctx context.Context, commentID string) error

func (*Client) DeleteReviewComment

func (c *Client) DeleteReviewComment(ctx context.Context, commentID string) error

func (*Client) EditConversationComment

func (c *Client) EditConversationComment(ctx context.Context, commentID, body string) error

func (*Client) EditReviewComment

func (c *Client) EditReviewComment(ctx context.Context, commentID, body string) error

func (*Client) Forget

func (c *Client) Forget(ctx context.Context, ref domain.PRRef) error

Forget drops the cached REST responses for the PR: the PR itself and everything under it, such as its commits.

func (*Client) PullRequest

func (c *Client) PullRequest(ctx context.Context, ref domain.PRRef) (domain.PullRequest, error)

func (*Client) RenderMarkdown

func (c *Client) RenderMarkdown(ctx context.Context, repo domain.Repo, body string) (string, error)

RenderMarkdown renders body through GitHub's Markdown API in GFM mode, which sanitises the HTML as comments are, and resolves issue references and mentions against repo.

func (*Client) Reply

func (c *Client) Reply(ctx context.Context, reviewID, threadID, body string) error

func (*Client) ReviewState

func (c *Client) ReviewState(ctx context.Context, ref domain.PRRef) (domain.ReviewState, error)

func (*Client) SetReaction

func (c *Client) SetReaction(ctx context.Context, subjectID string, r domain.Reaction, on bool) error

func (*Client) SetThreadResolved

func (c *Client) SetThreadResolved(ctx context.Context, threadID string, resolved bool) error

func (*Client) SetViewed

func (c *Client) SetViewed(ctx context.Context, prID, path string, viewed bool) error

func (*Client) StartReview

func (c *Client) StartReview(ctx context.Context, prID string, commit domain.SHA) (string, error)

func (*Client) Status

func (c *Client) Status() codehost.Status

Status reports whether the last request reached GitHub, and the most constrained rate limit seen.

func (*Client) SubmitReview

func (c *Client) SubmitReview(ctx context.Context, prID, reviewID string, commit domain.SHA, event domain.ReviewEvent, body string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL