github

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package github talks to the GitHub API: repository discovery, size estimates for the disk budget and the activity feed that names commits a clone can no longer see.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Token

func Token() string

Token returns the GitHub token from GITHUB_TOKEN, GH_TOKEN or the gh CLI, or "" when none is available. Public repositories work without one, but with a much lower API rate limit.

Types

type Client

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

Client wraps the go-github client with the calls patty needs.

func NewClient

func NewClient(token string) (*Client, error)

NewClient returns a client; token may be empty for anonymous access.

func NewClientWithBaseURL

func NewClientWithBaseURL(baseURL string) *Client

NewClientWithBaseURL is for tests against a fake API.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, owner string, opts ListOptions) ([]Repo, error)

ListRepos lists the repositories of a user or organization. For the authenticated user this includes private repositories.

func (*Client) Repo

func (c *Client) Repo(ctx context.Context, owner, name string) (Repo, error)

Repo fetches one repository.

func (*Client) Rewrites

func (c *Client) Rewrites(ctx context.Context, owner, name string, maxPages int) ([]Rewrite, error)

Rewrites reads the repository activity feed for force pushes and branch deletions. The Before SHA of each entry is a commit no clone fetches by default, but GitHub still serves it by SHA. maxPages caps the API calls per activity type (100 events per page).

type ListOptions

type ListOptions struct {
	IncludeForks    bool
	IncludeArchived bool
}

ListOptions filters ListRepos.

type Repo

type Repo struct {
	Owner    string
	Name     string
	SizeKB   int
	Fork     bool
	Archived bool
	Private  bool
	Empty    bool
}

Repo is what patty needs to know about a repository before cloning it.

func (Repo) CloneURL

func (r Repo) CloneURL() string

CloneURL returns the HTTPS clone URL.

func (Repo) FullName

func (r Repo) FullName() string

FullName returns owner/name.

type Rewrite

type Rewrite struct {
	Before    string    `json:"before"`
	After     string    `json:"after,omitempty"`
	Ref       string    `json:"ref"`
	Type      string    `json:"type"`
	Actor     string    `json:"actor,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

Rewrite is a ref update that made commits unreachable on the server: a force push replaced Before with After, or a branch deletion removed Before.

func (Rewrite) Describe

func (r Rewrite) Describe() string

Describe renders the rewrite for a report.

Jump to

Keyboard shortcuts

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