ghapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ghapi implements backend.Repo over the GitHub REST API v3 with a hand-rolled net/http client. It owns auth headers, conditional requests (ETag), Link-header pagination, and rate-limit errors. LastCommit and Blame return backend.ErrUnsupported: REST has no affordable shape for either (GraphQL does, later milestone).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimitError

type RateLimitError = backend.RateLimitError

RateLimitError is the shared backend type; the alias keeps the natural name available to ghapi callers.

type Repo

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

Repo is a backend.Repo bound to one owner/repo on one API host.

func New

func New(owner, repo, token string) *Repo

New returns a Repo talking to api.github.com. An empty token means anonymous access (60 requests/hour instead of 5000).

func NewWithBaseURL

func NewWithBaseURL(owner, repo, token, baseURL string, client *http.Client) *Repo

NewWithBaseURL is New with the API host and HTTP client injectable, which tests use to point at a mock server. A nil client means http.DefaultClient.

func (*Repo) Archive

func (r *Repo) Archive(ctx context.Context, rev, format, prefix string, w io.Writer) error

func (*Repo) Blame

func (r *Repo) Blame(ctx context.Context, rev, pth string) ([]backend.BlameHunk, error)

func (*Repo) Blob

func (r *Repo) Blob(ctx context.Context, rev, pth string) (backend.Blob, error)

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, sha string) (backend.CommitDetail, error)

func (*Repo) Commits

func (r *Repo) Commits(ctx context.Context, rev, pth string, n, skip int) ([]backend.Commit, bool, error)

func (*Repo) Files

func (r *Repo) Files(ctx context.Context, rev string) ([]string, error)

func (*Repo) Info

func (r *Repo) Info(ctx context.Context) (backend.Info, error)

func (*Repo) LastCommit

func (r *Repo) LastCommit(ctx context.Context, rev, pth string) (backend.Commit, error)

func (*Repo) Refs

func (r *Repo) Refs(ctx context.Context) (backend.Refs, error)

func (*Repo) Resolve

func (r *Repo) Resolve(ctx context.Context, ref string) (string, error)

func (*Repo) Tree

func (r *Repo) Tree(ctx context.Context, rev, pth string) ([]backend.TreeEntry, error)

Jump to

Keyboard shortcuts

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