github

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package github provides GitHub API client functionality for gh-find.

Index

Constants

This section is empty.

Variables

ValidRepoTypes is the list of valid repository type values.

Functions

This section is empty.

Types

type Client

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

Client wraps the go-gh REST and GraphQL clients.

func NewClient

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

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

func (*Client) GetFileCommitDates added in v1.0.0

func (c *Client) GetFileCommitDates(ctx context.Context, repo Repository, paths []string) ([]FileCommitInfo, error)

GetFileCommitDates fetches the last commit date for multiple files.

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, types RepoTypes) ([]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 FileCommitInfo added in v1.0.0

type FileCommitInfo struct {
	Path          string
	CommittedDate time.Time
}

FileCommitInfo holds the last commit timestamp for a file.

type FileType added in v0.9.2

type FileType string

FileType represents a file type classification.

const (
	// FileTypeFile represents a regular file.
	FileTypeFile FileType = "file"
	// FileTypeDirectory represents a directory.
	FileTypeDirectory FileType = "directory"
	// FileTypeSymlink represents a symbolic link.
	FileTypeSymlink FileType = "symlink"
	// FileTypeExecutable represents an executable file.
	FileTypeExecutable FileType = "executable"
	// FileTypeSubmodule represents a Git submodule.
	FileTypeSubmodule FileType = "submodule"
)

func ParseFileType added in v0.9.2

func ParseFileType(mode string) FileType

ParseFileType returns the file type based on Git mode.

type OwnerType

type OwnerType string

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

const (
	// OwnerTypeUser represents a user account.
	OwnerTypeUser OwnerType = "User"
	// OwnerTypeOrganization represents an organization account.
	OwnerTypeOrganization OwnerType = "Organization"
)

type RepoType

type RepoType string

RepoType represents a GitHub repository classification.

const (
	// RepoTypeSources represents source repositories (non-forks).
	RepoTypeSources RepoType = "sources"
	// RepoTypeForks represents forked repositories.
	RepoTypeForks RepoType = "forks"
	// RepoTypeArchives represents archived repositories.
	RepoTypeArchives RepoType = "archives"
	// RepoTypeMirrors represents mirrored repositories.
	RepoTypeMirrors RepoType = "mirrors"
)

type RepoTypes added in v0.9.2

type RepoTypes struct {
	Sources  bool
	Forks    bool
	Archives bool
	Mirrors  bool
}

RepoTypes represents a set of repository types to include.

func (RepoTypes) All added in v0.9.2

func (r RepoTypes) All() RepoTypes

All returns a RepoTypes with all types enabled.

func (RepoTypes) String added in v0.9.2

func (r RepoTypes) String() string

type Repository

type Repository struct {
	Owner       string `json:"-"`
	Name        string `json:"name"`
	FullName    string `json:"full_name"`
	Ref         string `json:"default_branch"`
	ExplicitRef bool   `json:"-"`
	URL         string `json:"html_url"`
	Size        int    `json:"size"`
	Fork        bool   `json:"fork"`
	Archived    bool   `json:"archived"`
	MirrorURL   string `json:"mirror_url"`
}

Repository represents a GitHub repository.

func (*Repository) UnmarshalJSON added in v0.9.4

func (r *Repository) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for Repository.

type TreeEntry

type TreeEntry struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
	Size int64  `json:"size"`
}

TreeEntry represents a file or directory in a Git tree.

type TreeResponse

type TreeResponse struct {
	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