github

package
v0.0.0-...-28091b0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

CacheDir returns the directory used for PR cache files.

func ReadBranchCache

func ReadBranchCache(cacheDir, org, repo string) map[string]string

ReadBranchCache reads cached worktree-to-branch mappings. Returns nil on miss or corruption.

func ReadUserCache

func ReadUserCache(cacheDir string) string

ReadUserCache reads the cached GitHub username. Returns "" on miss.

func WriteBranchCache

func WriteBranchCache(cacheDir, org, repo string, branches map[string]string)

WriteBranchCache writes worktree-to-branch mappings to a cache file.

func WritePRCache

func WritePRCache(cacheDir, org, repo string, prs []PR)

WritePRCache writes PR data to a cache file atomically. Errors are silently swallowed (best-effort).

func WriteUserCache

func WriteUserCache(cacheDir, login string)

WriteUserCache writes the GitHub username to a cache file.

Types

type CheckRun

type CheckRun struct {
	Name       string `json:"name"`
	Conclusion string `json:"conclusion"`
	Status     string `json:"status"`
}

CheckRun represents a single CI check.

type Client

type Client interface {
	PRsForRepo(org, repo string) ([]PR, error)
	MergedPRsForRepo(org, repo string) ([]PR, error)
	PRFromNumber(org, repo string, number int) (*PR, error)
	PRDetail(org, repo string, number int) (PRDetailResult, error)
	WorkflowRuns(org, repo, branch string, limit int) ([]WorkflowRun, error)
}

Client abstracts GitHub API access for testability.

type LiveClient

type LiveClient struct{}

LiveClient calls the real gh CLI.

func (LiveClient) MergedPRsForRepo

func (LiveClient) MergedPRsForRepo(org, repo string) ([]PR, error)

func (LiveClient) PRDetail

func (LiveClient) PRDetail(org, repo string, number int) (PRDetailResult, error)

func (LiveClient) PRFromNumber

func (LiveClient) PRFromNumber(org, repo string, number int) (*PR, error)

func (LiveClient) PRsForRepo

func (LiveClient) PRsForRepo(org, repo string) ([]PR, error)

func (LiveClient) WorkflowRuns

func (LiveClient) WorkflowRuns(org, repo, branch string, limit int) ([]WorkflowRun, error)

type PR

type PR struct {
	Number         int    `json:"number"`
	Title          string `json:"title"`
	HeadRefName    string `json:"headRefName"`
	State          string `json:"state"`
	ReviewDecision string `json:"reviewDecision"`
	StatusRollup   string `json:"statusRollup"` // derived from statusCheckRollup
	URL            string `json:"url"`
	Author         string `json:"authorLogin"` // GitHub login; extracted from nested author.login via extractAuthor(); tag avoids collision with gh's "author" object
	MergedAt       string `json:"mergedAt"`
}

PR represents a pull request associated with a branch.

func MergedPRsForRepo

func MergedPRsForRepo(org, repo string) ([]PR, error)

MergedPRsForRepo returns recently merged PRs for a given org/repo.

func PRFromNumber

func PRFromNumber(org, repo string, number int) (*PR, error)

PRFromNumber fetches a specific PR by number.

func PRsForRepo

func PRsForRepo(org, repo string) ([]PR, error)

PRsForRepo returns open PRs for a given org/repo.

func ReadPRCache

func ReadPRCache(cacheDir, org, repo string) ([]PR, error)

ReadPRCache reads cached PR data for a repo. Returns nil, nil on miss or corruption.

type PRDetailResult

type PRDetailResult struct {
	Title   string
	Body    string
	Checks  []CheckRun
	Commits []string
}

PRDetailResult holds all data returned by PRDetail.

func PRDetail

func PRDetail(org, repo string, number int) (PRDetailResult, error)

PRDetail fetches the body, check runs, and recent commits for a PR.

type WorkflowRun

type WorkflowRun struct {
	Name       string `json:"name"`
	Status     string `json:"status"`     // completed, in_progress, queued
	Conclusion string `json:"conclusion"` // success, failure, cancelled, etc.
	CreatedAt  string `json:"createdAt"`
}

WorkflowRun represents a GitHub Actions workflow run.

func WorkflowRuns

func WorkflowRuns(org, repo, branch string, limit int) ([]WorkflowRun, error)

WorkflowRuns returns recent workflow runs for a repo/branch.

Jump to

Keyboard shortcuts

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