github

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package github implements `sf github ci` — a compact view of a repo's GitHub Actions runs via the `gh` CLI, with an optional `--watch` that blocks until the latest run finishes and prints only its final status (instead of gh's verbose live stream). Targets a single package dir (by name) or the current repo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `github` group (`sf github …`).

func RunBranches

func RunBranches(opts BranchOptions, w io.Writer) error

RunBranches reports non-default branches across the viewer's own repos and, with --delete, removes the ones whose PR is already merged (or closed).

func RunCI

func RunCI(opts Options, w io.Writer) error

RunCI lists (or watches) a repo's CI runs, renders them, and logs the call. In --watch mode it returns a non-nil error when the watched run concludes in failure, so the process exit code mirrors `gh run watch --exit-status`.

func RunPR

func RunPR(opts PROptions, w io.Writer) error

RunPR digests the viewer's open PRs across all repos into a compact table, then logs the call.

Types

type Branch

type Branch struct {
	Repo    string `json:"repo"`   // nameWithOwner
	Branch  string `json:"branch"` // head ref name (may contain slashes)
	AgeDays int    `json:"age_days"`
	PR      string `json:"pr"`     // "MERGED#11" | "OPEN#15" | "CLOSED#4" | "none"
	Status  string `json:"status"` // merged | closed | open | no-pr
}

Branch is one non-default branch on an owned repo, reduced to what you need to decide whether it can go: where it lives, how stale it is, and the state of the pull request it belongs to (the source of truth for "already merged").

type BranchOptions

type BranchOptions struct {
	Format string
	Delete string // "" (report only) | "merged" | "closed" (closed implies merged)
	Refs   int    // max branches fetched per repo
}

BranchOptions controls a `github branches` run.

type Options

type Options struct {
	Root    string
	Target  string // package name / dir basename / path; empty = current repo
	Format  string
	Limit   int
	Watch   bool
	Timeout time.Duration
	Poll    time.Duration
}

Options controls a `github ci` run.

type PR

type PR struct {
	Repo   string `json:"repo"`
	Number int    `json:"number"`
	CI     string `json:"ci"`     // statusCheckRollup.state, normalised (SUCCESS/FAILURE/PENDING/NONE)
	Review string `json:"review"` // reviewDecision (APPROVED/CHANGES_REQUESTED/REVIEW_REQUIRED/NONE)
	Role   string `json:"role"`   // author | reviewer | "–" (open PR on your repo, e.g. a bot's)
	Draft  bool   `json:"draft"`
	Title  string `json:"title"`
	URL    string `json:"url"`
}

PR is one open pull request across the user's repos, collapsed to the few fields an agent actually needs to triage it: where it lives, its CI rollup, its review verdict, and the user's role on it.

type PROptions

type PROptions struct {
	Format string
	Limit  int
}

PROptions controls a `github pr` run.

type PkgCI

type PkgCI struct {
	Pkg string `json:"pkg"`
	Run
}

PkgCI is one package's latest CI run in the aggregate (tree) view. The embedded Run is zero when the package has no runs or could not be probed.

type Run

type Run struct {
	ID         int64  `json:"id"`
	Workflow   string `json:"workflow"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	Branch     string `json:"branch"`
	Event      string `json:"event"`
	Title      string `json:"title"`
	CreatedAt  string `json:"created"`
}

Run is one GitHub Actions workflow run.

Jump to

Keyboard shortcuts

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