github

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package github reads gh-* extensions from github.com anonymously. It has no way to send credentials: gt's accounts belong to Gitea instances, and a GitHub token must never be guessed from the environment.

Index

Constants

View Source
const Host = "https://github.com"

Host is the instance URL extensions from GitHub are recorded with.

Variables

View Source
var ErrNotFound = errors.New("not found on GitHub")

ErrNotFound reports a repository, release or file GitHub does not have.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	URL  string `json:"browser_download_url"`
	// Digest is "sha256:HEX" for assets GitHub recorded a digest for.
	Digest string `json:"digest"`
}

Asset is a GitHub release asset.

func (Asset) SHA256

func (a Asset) SHA256() string

SHA256 returns the asset's recorded SHA-256, or "".

type Client

type Client struct {
	// API is the REST API root, https://api.github.com unless a test replaces it.
	API  string
	HTTP *http.Client
}

Client reads public repositories and releases from GitHub.

func New

func New() Client

New returns an anonymous client with a timeout.

func (Client) Commit

func (c Client) Commit(ctx context.Context, owner, repo, ref string) (string, error)

Commit resolves ref to its commit SHA.

func (Client) Download

func (c Client) Download(ctx context.Context, asset Asset) (io.ReadCloser, error)

Download opens the content of an asset, which must be served over HTTPS.

func (Client) File

func (c Client) File(ctx context.Context, owner, repo, ref, path string) ([]byte, bool, error)

File returns the content of path at ref, and whether it exists.

func (Client) Release

func (c Client) Release(ctx context.Context, owner, repo, tag string) (Release, error)

Release returns the release tagged tag, or the latest release when tag is empty.

func (Client) Repository

func (c Client) Repository(ctx context.Context, owner, repo string) (Repository, error)

Repository returns the public repository owner/repo.

type Release

type Release struct {
	Tag    string  `json:"tag_name"`
	Assets []Asset `json:"assets"`
}

Release is a GitHub release.

type Repository

type Repository struct {
	ID            int64  `json:"id"`
	Name          string `json:"name"`
	DefaultBranch string `json:"default_branch"`
	HTMLURL       string `json:"html_url"`
	CloneURL      string `json:"clone_url"`
	Owner         struct {
		Login string `json:"login"`
	} `json:"owner"`
}

Repository is a GitHub repository.

Jump to

Keyboard shortcuts

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