Documentation
¶
Overview ¶
Package github provides GitHub API integration.
Index ¶
- Constants
- func AuthMethod() string
- func GetToken() (string, error)
- func GetTokenFromEnv() string
- func GetTokenFromGHCLI() (string, error)
- func IsGHCLIAvailable() bool
- func IsGHCLIInstalled() bool
- type Client
- func (c *Client) FetchFile(ctx context.Context, owner, repo, path, branch string) (*FetchResult, error)
- func (c *Client) FileExists(ctx context.Context, owner, repo, path, branch string) (bool, error)
- func (c *Client) GetDefaultBranch(ctx context.Context, owner, repo string) (string, error)
- func (c *Client) ListDirectory(ctx context.Context, owner, repo, path, branch string) ([]DirectoryEntry, error)
- func (c *Client) RepoExists(ctx context.Context, owner, repo string) (bool, error)
- type DirectoryEntry
- type FetchResult
Constants ¶
const (
// EnvGitHubToken is the environment variable for fallback token auth.
EnvGitHubToken = "STAGHORN_GITHUB_TOKEN"
)
Variables ¶
This section is empty.
Functions ¶
func AuthMethod ¶
func AuthMethod() string
AuthMethod returns a string describing the current auth method.
func GetToken ¶
GetToken resolves a GitHub token using the auth chain. Priority: 1) gh auth token, 2) STAGHORN_GITHUB_TOKEN env
func GetTokenFromGHCLI ¶
GetTokenFromGHCLI executes `gh auth token` to get token.
func IsGHCLIAvailable ¶
func IsGHCLIAvailable() bool
IsGHCLIAvailable checks if the gh CLI is installed and authenticated.
func IsGHCLIInstalled ¶
func IsGHCLIInstalled() bool
IsGHCLIInstalled checks if the gh CLI binary is installed (but not necessarily authenticated).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API for staghorn's needs.
func NewClientWithToken ¶
NewClientWithToken creates a GitHub client with explicit token.
func (*Client) FetchFile ¶
func (c *Client) FetchFile(ctx context.Context, owner, repo, path, branch string) (*FetchResult, error)
FetchFile fetches a file from a repo. If etag is provided and content hasn't changed, returns NotModified=true.
func (*Client) FileExists ¶
FileExists checks if a file exists in a repo.
func (*Client) GetDefaultBranch ¶
GetDefaultBranch returns the repo's default branch.
func (*Client) ListDirectory ¶
func (c *Client) ListDirectory(ctx context.Context, owner, repo, path, branch string) ([]DirectoryEntry, error)
ListDirectory lists contents of a directory in a repo. Returns nil, nil if the directory doesn't exist.