github

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheTTL = 60 * time.Second

DefaultCacheTTL is the TTL applied when caching is enabled and no other value is specified. Kept short because PR state (CI, review decision, merge status) can change minute-to-minute.

Variables

This section is empty.

Functions

func DecodeForTests

func DecodeForTests(raw []byte) (*model.Repo, error)

DecodeForTests decodes a GraphQL response envelope captured as JSON (matching the shape of testdata/fixtures/*.json) into a *model.Repo. Exported solely so internal/render tests can drive golden comparisons. Do not use in production code.

func DefaultCacheDir

func DefaultCacheDir() string

DefaultCacheDir returns the per-user cache directory for gh-prs entries. Falls back to a sibling of the binary's temp dir if UserCacheDir is not resolvable (very rare on macOS/Linux; e.g. HOME unset in a sandbox).

func ParseCacheTTL

func ParseCacheTTL(raw string) (time.Duration, bool)

ParseCacheTTL parses a human duration string (e.g. "60s", "2m"). Empty or invalid input returns (DefaultCacheTTL, false) so callers can distinguish "defaulted" from "explicitly set".

Types

type Client

type Client interface {
	FetchRepo(ctx context.Context, filters filter.Set) (*model.Repo, error)
}

func New

func New(opts Options) (Client, error)

type Options

type Options struct {
	// Debug enables httpretty-style logging of the GraphQL request/response
	// (URL, headers, body, timing) to DebugOut. Honors DebugColor for ANSI.
	Debug      bool
	DebugOut   io.Writer
	DebugColor bool

	// EnableCache turns on go-gh's disk cache for the GraphQL POST. When on,
	// identical queries within CacheTTL are served from CacheDir without a
	// network round trip. CacheDir empty => go-gh default.
	EnableCache bool
	CacheTTL    time.Duration
	CacheDir    string
}

Options configures the GitHub client. Zero-value is safe: no debug, no cache.

Jump to

Keyboard shortcuts

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