Documentation
¶
Overview ¶
Package github fetches the viewer's pull requests from the GitHub GraphQL API and maps them into domain types. It is the only package that knows the wire format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSearch ¶
BuildSearch returns the search string: every PR the viewer authored or is assigned to, open or closed inside the window. DATE is date-granular, so it carries one extra day of margin. sort:updated-desc filters nothing; it makes a page-capped list keep the most recently updated PRs. There is deliberately no archived:false qualifier: open PRs in archived repositories must be listed.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches pull requests. It implements ui.Fetcher.
func NewClient ¶
NewClient builds a Client. The token is passed explicitly and never logged: LogIgnoreEnv stops GH_DEBUG from writing HTTP traffic over the screen, and the response cache stays off so polling never shows stale data.
func (*Client) Fetch ¶
Fetch runs the discovery query page by page, de-duplicates by node id, merges in the saved watch list (the saved PRs that discovery did not return are looked up, in chunks), keeps the PRs inside the closed window and orders them for display. A Lookup that fails as a whole fails the refresh, so the rows on screen stay. It then names the failing check of every failing PR with a second query (D-01), inside the same call, so the whole refresh stays one single-flight fetch.
func (*Client) FetchDetail ¶
FetchDetail returns the full detail of one pull request: its de-duplicated, sorted checks, every reviewer with their state, and the counts.
Contexts are read 100 at a time for at most maxPages pages. Counts always come from the de-duplicated checks of the pages read (D-03), so a run superseded on another page is not counted. Truncated is set only when check runs were not read: the pull request has more runs than the page cap reads, a later page fails, or fewer runs were read than GitHub reports (for example nodes that GraphQL returned as null). Read and Total say how many runs were read of how many exist. Partial is set separately when any page came back with a GraphQL error whose data was kept, because a check, a reviewer or a review request may then be missing (G-03-6, WR-05). A failure on page 1 is returned; so are a rate limit and a cancelled context on any page.
func (*Client) Lookup ¶
Lookup loads one PR by ref for the add prompt (D-02). A PR that cannot be read comes back with Unavail set; an error means the request failed as a whole. A PR with failing CI also gets its failing check named, so the new row looks like every other. It may run while Fetch runs: the two share only the GraphQL client and the header capture, which are safe for concurrent use.
type Error ¶
type Error struct {
Kind ErrorKind
Status int
Message string
// RetryAfter and ResetAt are set for KindRateLimited when GitHub sent
// them; zero means absent.
RetryAfter time.Duration
ResetAt time.Time
// contains filtered or unexported fields
}
Error is a failed fetch, described for the user. Its text is built only from the HTTP status, fixed strings and a cleaned API message: never from headers, request dumps or the token.
func (*Error) Backoff ¶
Backoff reports how long GitHub asked prv to wait (Retry-After), when the limit resets, and whether this failure is a rate limit at all. The ui reads it through its own interface.
type ErrorKind ¶
type ErrorKind int
ErrorKind says what kind of failure GitHub or the network produced.
type Options ¶
type Options struct {
Token string
ClosedDays int
Now func() time.Time
Transport http.RoundTripper // nil means the default transport; tests inject a fake
Watch WatchSource // nil means no saved list
}
Options configures a Client.