github

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the error represents an HTTP 404 response from the GitHub API. Used to distinguish "file not found" from auth failures, rate limits, and other errors that should not be silently ignored.

func NewClient

func NewClient(cfg ClientConfig) (*gh.Client, error)

NewClient creates an authenticated GitHub API client. Auth resolution order: Token → App key content → App key file → error.

func ResolveBaseURL

func ResolveBaseURL(flagValue string) string

ResolveBaseURL resolves the GitHub API base URL from the flag value or the GITHUB_API_URL environment variable. Returns empty string for github.com.

Types

type ClientConfig

type ClientConfig struct {
	// Token is a GitHub personal access token or GITHUB_TOKEN.
	// Falls back to GITHUB_TOKEN env var if empty.
	Token string

	// AppID is the GitHub App ID for app authentication.
	// Falls back to GH_APP_ID env var if zero.
	AppID int64

	// AppKey is the PEM-encoded GitHub App private key content.
	// Falls back to GH_APP_PRIVATE_KEY env var if empty.
	AppKey string

	// AppKeyPath is the path to a GitHub App private key PEM file.
	// Falls back to GH_APP_PRIVATE_KEY_PATH env var if empty.
	AppKeyPath string

	// BaseURL is a custom GitHub API base URL for GitHub Enterprise.
	// Falls back to GITHUB_API_URL env var if empty.
	BaseURL string

	// Owner is the repository owner, used for auto-detecting the app installation.
	Owner string
}

ClientConfig holds the configuration for creating a GitHub API client.

type GitHubRepository

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

GitHubRepository implements git.Repository using the GitHub API.

func NewGitHubRepository

func NewGitHubRepository(client *gh.Client, owner, repo string, opts ...Option) *GitHubRepository

NewGitHubRepository creates a new GitHubRepository.

func (*GitHubRepository) BranchCommits

func (r *GitHubRepository) BranchCommits(branch git.Branch, filters ...git.PathFilter) ([]git.Commit, error)

func (*GitHubRepository) Branches

func (r *GitHubRepository) Branches(_ ...git.PathFilter) ([]git.Branch, error)

func (*GitHubRepository) BranchesContainingCommit

func (r *GitHubRepository) BranchesContainingCommit(sha string) ([]git.Branch, error)

func (*GitHubRepository) CommitFromSha

func (r *GitHubRepository) CommitFromSha(sha string) (git.Commit, error)

func (*GitHubRepository) CommitLog

func (r *GitHubRepository) CommitLog(from, to string, filters ...git.PathFilter) ([]git.Commit, error)

func (*GitHubRepository) CommitsPriorTo

func (r *GitHubRepository) CommitsPriorTo(olderThan time.Time, branch git.Branch) ([]git.Commit, error)

func (*GitHubRepository) FetchFileContent

func (r *GitHubRepository) FetchFileContent(path string) (string, error)

FetchFileContent fetches a file's content from the repository. Used to load configuration files from the remote repository.

func (*GitHubRepository) FindMergeBase

func (r *GitHubRepository) FindMergeBase(sha1, sha2 string) (string, error)

func (*GitHubRepository) Head

func (r *GitHubRepository) Head() (git.Branch, error)

func (*GitHubRepository) IsHeadDetached

func (r *GitHubRepository) IsHeadDetached() bool

func (*GitHubRepository) MainlineCommitLog

func (r *GitHubRepository) MainlineCommitLog(from, to string, filters ...git.PathFilter) ([]git.Commit, error)

func (*GitHubRepository) NumberOfUncommittedChanges

func (r *GitHubRepository) NumberOfUncommittedChanges() (int, error)

func (*GitHubRepository) Path

func (r *GitHubRepository) Path() string

func (*GitHubRepository) PeelTagToCommit

func (r *GitHubRepository) PeelTagToCommit(tag git.Tag) (string, error)

func (*GitHubRepository) Tags

func (r *GitHubRepository) Tags(_ ...git.PathFilter) ([]git.Tag, error)

func (*GitHubRepository) WorkingDirectory

func (r *GitHubRepository) WorkingDirectory() string

type Option

type Option func(*GitHubRepository)

Option configures a GitHubRepository.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the GitHub API base URL for GitHub Enterprise.

func WithMaxCommits

func WithMaxCommits(n int) Option

WithMaxCommits sets the hard cap on commit walk depth.

func WithRef

func WithRef(ref string) Option

WithRef sets the target ref for HEAD resolution.

Jump to

Keyboard shortcuts

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