github

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the go-gh REST client.

func NewClient

func NewClient(opts ClientOptions) (*Client, error)

NewClient creates a new GitHub API client with the given options.

func (*Client) GetOwnerType

func (c *Client) GetOwnerType(ctx context.Context, name string) (OwnerType, error)

GetOwnerType determines if a name is a "User" or "Organization".

func (*Client) GetRepo

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

GetRepo fetches a single repository.

func (*Client) GetTree

func (c *Client) GetTree(ctx context.Context, repo *Repository) (*TreeResponse, error)

GetTree fetches the Git tree for a repository recursively.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, name string, repoTypes []RepoType) ([]*Repository, error)

ListRepos returns all repositories for a user or organization with pagination. It detects whether the name is a user or org and uses the appropriate endpoint.

type ClientOptions

type ClientOptions struct {
	AuthToken    string
	CacheDir     string
	CacheTTL     time.Duration
	DisableCache bool
}

ClientOptions configures the GitHub API client.

type OwnerType

type OwnerType string

OwnerType represents the type of account owner (User or Organization).

const (
	OwnerTypeUser         OwnerType = "User"
	OwnerTypeOrganization OwnerType = "Organization"
)

type RepoType

type RepoType string

RepoType represents a GitHub repository classification.

const (
	RepoTypeSources  RepoType = "sources"
	RepoTypeForks    RepoType = "forks"
	RepoTypeArchives RepoType = "archives"
	RepoTypeMirrors  RepoType = "mirrors"
	RepoTypeAll      RepoType = "all"
)

type Repository

type Repository struct {
	Owner         string
	Name          string
	FullName      string // owner/name
	DefaultBranch string
	Fork          bool
	Archived      bool
	MirrorURL     string
}

Repository represents a GitHub repository.

type TreeEntry

type TreeEntry struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
	Type string `json:"type"` // blob, tree
	SHA  string `json:"sha"`
	Size int64  `json:"size"`
	URL  string `json:"url"`
}

TreeEntry represents a file or directory in a Git tree.

type TreeResponse

type TreeResponse struct {
	SHA       string      `json:"sha"`
	URL       string      `json:"url"`
	Tree      []TreeEntry `json:"tree"`
	Truncated bool        `json:"truncated"`
}

TreeResponse represents the GitHub API tree response.

Jump to

Keyboard shortcuts

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