github

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github is a client for the pieces of the GitHub API forge-dashboard needs: which repositories the credential can write to, their open pull requests and issues, and combined CI status per pull request. With a token, it talks to GitHub's GraphQL API — one request returns everything a REST-based Client used to need one call per repo/PR/CI-check for, and GraphQL draws from its own separate rate-limit pool rather than the REST budget every other tool on the account shares. GraphQL requires authentication for every request, so the username-only (public repos, no token) mode still uses REST — a fallback path that was never part of the authenticated budget anyway.

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 GitHub, either as an authenticated user (a token, GraphQL) or anonymously against one user's public repositories (a username, no token, REST — GraphQL allows no anonymous access at all). The REST fallback is driven by google/go-github rather than hand-rolled requests — same wire calls, typed responses and typed rate-limit errors instead of reparsing JSON bodies by hand.

func NewClient

func NewClient(token, username, baseURL string) *Client

NewClient returns a Client. With token set, Fetch queries GraphQL for every repo the token can push to, private included. With token empty and username set, Fetch falls back to unauthenticated REST and returns only username's public repos — there's no "write access" to filter by without a credential, so this mode returns everything public GitHub already shows anyone. baseURL defaults to the real GitHub API; tests override it to point at an httptest.Server.

func (*Client) Fetch added in v0.37.0

func (c *Client) Fetch(ctx context.Context) dashboard.Result

Fetch implements dashboard.Source directly — GitHub drives its own fetch strategy (GraphQL vs. the REST fallback) rather than going through dashboard.GenericSource's one-call-per-repo model, which is exactly the round-trip count this exists to avoid.

func (*Client) FetchRepo added in v0.40.0

func (c *Client) FetchRepo(ctx context.Context, owner, name, fullName string) ([]dashboard.PullRequest, []dashboard.Issue, error)

FetchRepo implements dashboard.RepoRefresher: the single-repo counterpart to Fetch's account-wide GraphQL query, for a webhook delivery that already knows exactly which repo changed.

func (*Client) Forge added in v0.38.0

func (c *Client) Forge() dashboard.Forge

Forge implements dashboard.Source.

Jump to

Keyboard shortcuts

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