Documentation
¶
Overview ¶
Package github adapts GitHub repositories and pull requests to forge contracts.
It uses go-github for tag and release catalogs, repository metadata, and pull request observation and writes. The shared internal/github client supplies authentication and transport policy; upstream and publish interpret the observations for a contribution.
Index ¶
- type Client
- func (c *Client) Account(ctx context.Context, instance, login string) (forge.Account, error)
- func (c *Client) Create(ctx context.Context, input forge.PullRequestInput) (forge.PullRequestObservation, error)
- func (c *Client) Describe(ctx context.Context, instance, name string) (forge.Description, error)
- func (c *Client) Document(ctx context.Context, address string, headers http.Header) ([]byte, bool, error)
- func (c *Client) FailedJobs(ctx context.Context, repository, head string) ([]forge.CIJob, error)
- func (c *Client) Find(ctx context.Context, q forge.PullRequestQuery) (forge.PullRequestObservation, error)
- func (c *Client) Inspect(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestStatus, error)
- func (c *Client) JobLog(ctx context.Context, repository string, job int64) ([]byte, error)
- func (c *Client) Login(ctx context.Context) (forge.Login, error)
- func (c *Client) MarkDraft(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
- func (c *Client) MarkReady(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
- func (c *Client) NameFromRemote(remote string) (string, error)
- func (c *Client) Observe(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
- func (c *Client) OpenPullRequests(ctx context.Context, repository, port string) ([]forge.PullRequestSummary, error)
- func (c *Client) Permission(ctx context.Context, repository, login string) (string, error)
- func (c *Client) PostReview(ctx context.Context, input forge.ReviewInput) (string, error)
- func (c *Client) ReadPullRequests(ctx context.Context, refs []forge.PullRequestRef) ([]forge.PullRequestReading, error)
- func (c *Client) Repository(instance, name string) (forge.Repository, error)
- func (c *Client) RepositoryInfo(ctx context.Context, name string) (forge.RepositoryInfo, error)
- func (c *Client) RequestReviewers(ctx context.Context, ref forge.PullRequestRef, logins []string) error
- func (c *Client) RequestsLeft(ctx context.Context) (int, time.Time, error)
- func (c *Client) RerunFailed(ctx context.Context, repository string, run int64) error
- func (c *Client) Update(ctx context.Context, input forge.PullRequestInput) (forge.PullRequestObservation, error)
- type Moves
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
*githubapi.Client
// Git reads tags with plain git when the API cannot.
Git git.Program
// Moves reads where a repository whose tags came from git moved, from
// GitHub's web page for it; none are read where nil.
Moves *Moves
}
func (*Client) Account ¶ added in v0.7.0
Account reads a login as GitHub has it now, one request (GET /users/{login}): none where GitHub answers 404, as for a name no one holds.
func (*Client) Create ¶
func (c *Client) Create(ctx context.Context, input forge.PullRequestInput) (forge.PullRequestObservation, error)
func (*Client) Describe ¶ added in v0.5.0
Describe reads a repository's description, by its owner/name, as the repository it binds says it (repository.Describe).
func (*Client) Document ¶
func (c *Client) Document(ctx context.Context, address string, headers http.Header) ([]byte, bool, error)
Document fetches a livecheck URL on the GitHub API through the client, so the user's credentials and the rate-limit handling apply, sending the caller's headers, which are Base's curl fetch's, in place of the SDK's user agent, Accept, and API version. The API lays its JSON out by those headers, and the maintainers' expressions are written against the indented form MacPorts receives; the SDK's own headers get the compact form. A URL off the API is not served. The body is bounded like a plain listing.
func (*Client) FailedJobs ¶ added in v0.5.0
FailedJobs are a head's GitHub Actions jobs that failed, of each run's latest attempt, through the documented endpoints: the repository's workflow runs for the head, and each run's jobs. It reads only.
func (*Client) Find ¶
func (c *Client) Find(ctx context.Context, q forge.PullRequestQuery) (forge.PullRequestObservation, error)
func (*Client) Inspect ¶
func (c *Client) Inspect(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestStatus, error)
Inspect reports mergeability, the latest review from each reviewer, check runs, and commit statuses for the pull request's current head. It reads only; nothing here reruns, comments, or merges.
func (*Client) JobLog ¶ added in v0.5.0
JobLog is a job's log, through its documented link ("Download job logs for a workflow run"), which redirects to where it's served, fetched as fetch fetches; each line without the time GitHub writes before it. One GitHub no longer keeps, or won't give this login, is forge.ErrNotFound.
func (*Client) Login ¶ added in v0.4.0
Login is who the client acts as, asked of GitHub, and where its token comes from (githubapi.Client.LoginStatus).
func (*Client) MarkDraft ¶ added in v0.7.0
func (c *Client) MarkDraft(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
MarkDraft returns a pull request ready for review to draft, and reports it as it then is. One already a draft is left alone.
func (*Client) MarkReady ¶
func (c *Client) MarkReady(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
MarkReady takes a draft pull request out of draft, so it is ready for review, and reports it as it then is. One already ready is left alone.
func (*Client) NameFromRemote ¶
NameFromRemote is the repository a remote's URL names on GitHub.
func (*Client) Observe ¶
func (c *Client) Observe(ctx context.Context, ref forge.PullRequestRef) (forge.PullRequestObservation, error)
func (*Client) OpenPullRequests ¶
func (c *Client) OpenPullRequests(ctx context.Context, repository, port string) ([]forge.PullRequestSummary, error)
OpenPullRequests finds a repository's open pull requests whose titles contain a word, as GitHub's search reads it; which of them name a port is MacPorts' subject rule, the caller's (commitmsg.SubjectPorts; the architecture review's H2).
func (*Client) Permission ¶
Permission is a person's role on a repository: admin, maintain, write, triage, read, or none.
func (*Client) PostReview ¶
PostReview posts a review on a pull request at the commit it reviewed, and returns the review's address.
func (*Client) ReadPullRequests ¶ added in v0.4.0
func (c *Client) ReadPullRequests(ctx context.Context, refs []forge.PullRequestRef) ([]forge.PullRequestReading, error)
ReadPullRequests reads the pull requests with GitHub's GraphQL API, twenty-five a request, where Observe and Inspect take about five requests each: the pull-request half of spending less of GitHub's allowance (the SQL study's O8). One GitHub hasn't is not Found; one with more reviews or checks than a reading takes is Partial.
func (*Client) Repository ¶
func (c *Client) Repository(instance, name string) (forge.Repository, error)
Repository validates a GitHub owner/name without making a network request.
func (*Client) RepositoryInfo ¶
func (*Client) RequestReviewers ¶
func (c *Client) RequestReviewers(ctx context.Context, ref forge.PullRequestRef, logins []string) error
RequestReviewers asks people to review a pull request again, as GitHub's "re-request review" does.
func (*Client) RequestsLeft ¶ added in v0.6.0
RequestsLeft is what's left of the hour's requests for the client's login, or without one, as GitHub says it (forge.AllowanceReader).
func (*Client) RerunFailed ¶ added in v0.5.0
RerunFailed runs a workflow run's failed jobs again, as the person whose login it is, through the documented endpoint ("Re-run failed jobs from a workflow run"), which needs write access to the repository: without it GitHub answers 403 or 404, which is forge.ErrRejected.
func (*Client) Update ¶
func (c *Client) Update(ctx context.Context, input forge.PullRequestInput) (forge.PullRequestObservation, error)
type Moves ¶ added in v0.8.0
type Moves struct {
// BaseURL is GitHub's web, https://github.com where empty; a test
// points it at a stub site.
BaseURL string
// HTTP sends the reads, which follow no redirect whatever it says;
// dockhand's own transport where nil.
HTTP *http.Client
// contains filtered or unexported fields
}
Moves reads where a repository moved from GitHub's web page for it, which answers a renamed or transferred repository with a 301 naming the new one, as GitHub documents, outside the API's limits and its pacer. GitHub's git serves a moved repository under its old name with no word of the move, so a repository whose tags came from git is asked here: a look's 416 repositories were asked in 26.6 s, eight at once, 20 of them moved, with no throttling (the web redirect's look, 2026-11-01). The page is no API contract, so whatever it doesn't answer as expected is left unsaid, and a 429 or a refusal pauses the reads; nothing waits on it but the note it gives. Each answer is kept seven days, a 200's and a 301's alike, in the process and in a file where one is given, so a daily look asks about sixty and serve's looks no more.