github

package
v0.3.0 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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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