github

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package github loads pull request status through the gh CLI.

Index

Constants

View Source
const Timeout = 20 * time.Second

Timeout bounds one FetchPRs call so a stuck gh cannot hang the app.

Variables

View Source
var (
	ErrNotGitHub = errors.New("origin is not a GitHub remote")
	ErrGhMissing = errors.New("gh CLI not found")
	ErrNoAccess  = errors.New("gh cannot access this repository")
)
View Source
var LookPath = exec.LookPath

LookPath locates executables; replaced in tests.

Functions

func FetchPRs

func FetchPRs(repoRoot string) (map[string]PR, error)

FetchPRs loads pull requests for the repo at repoRoot via gh, within Timeout.

func FetchPRsContext

func FetchPRsContext(ctx context.Context, repoRoot string) (map[string]PR, error)

FetchPRsContext is FetchPRs bounded by ctx. gh is told never to prompt.

func ParsePRs

func ParsePRs(data []byte) (map[string]PR, error)

ParsePRs parses `gh pr list --json` output into a map keyed by head branch. When a branch has several PRs, an open one wins; otherwise the highest number.

Types

type PR

type PR struct {
	Number     int
	Title, URL string
	Head, Base string
	State      PRState
}

PR is a pull request, reduced to what the UI needs.

type PRState

type PRState int

PRState is the display state of a pull request.

const (
	PROpen PRState = iota
	PRDraft
	PRApproved
	PRChangesRequested
	PRMerged
	PRClosed
)

Jump to

Keyboard shortcuts

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