github

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package github lists and mirrors repositories from GitHub.com over its REST API.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingRepoScope = errors.New(`github token is missing the "repo" scope: private repositories would not be listed`)

ErrMissingRepoScope means a classic personal access token's granted scopes don't include "repo". GitHub doesn't error on that -- /user/repos still returns 200 with just the public repositories -- so left unchecked this is a backup that silently never carried anything private.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL *url.URL
	Token   string
	HTTP    *http.Client
}

Client lists and mirrors repositories from GitHub.com.

func New

func New(base, token string) (*Client, error)

New builds a Client. An empty base uses GitHub.com's own API host; a test points it at a recorded fixture server instead.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, state backup.State) ([]backup.Repo, error)

ListRepos implements backup.Lister by paging through GET /user/repos for the authenticated token. That endpoint has no server-side archived filter, unlike Forgejo's search or GitLab's projects endpoint, so every repo is fetched once and filtered by state locally. GitHub's repo object carries no "is this repo empty" field either; size is reported in kilobytes and a repo with no commits pushed yet reports 0, which is what Empty is derived from.

func (*Client) Remote

func (c *Client) Remote(r backup.Repo) backup.Remote

Remote implements backup.Remoter. GitHub accepts a personal access token as the Basic auth username with an empty password, the same form as `git clone https://<token>@github.com/owner/repo.git`.

Jump to

Keyboard shortcuts

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