Documentation
¶
Overview ¶
Package config reads prs's config file, which names the registry of repos or the owners read in its place, how often the board reads them, how large a diff a pull request's document shows whole, the keys a person adds to it, and the fixes and worktree root the menu of a pull request that cannot merge uses.
Index ¶
- Constants
- Variables
- func ClosedPullRequestsDir() (string, error)
- func DefaultRegistry() (string, error)
- func Fill(template string, fields Fields) string
- func FillCommand(template string, fields Fields) string
- func FillRecap(argv []string, fields RecapFields) []string
- func FixPlaceholders() []string
- func ListingCacheDir() (string, error)
- func MissingPrograms(programs []string) []string
- func Path() (string, error)
- func Placeholders() []string
- func RecapPlaceholders() []string
- func RecapWritesDir() (string, error)
- func ShellQuotedPlaceholders() []string
- func TUIDisplayFile() (string, error)
- type Config
- type Fields
- type MergeFix
- type RecapFields
- type Recaps
- type WindowAction
Constants ¶
const ( FromVariable = RegistryVariable FromFile = "repos_registry in the config file" FromOwners = "owners in the config file" FromDefault = "the default" FromViewer = "no registry at the default, so your own repos on GitHub" )
Which layer chose the repos prs reads, in the order they are asked.
const ( Conflicts = "conflicts" Behind = "behind" FailingChecks = "failing-checks" Draft = "draft" )
The kinds of blocker a merge fix names, as the fix's command receives them in {blocker}.
const DefaultClosedRefreshEvery = 5 * time.Minute
DefaultClosedRefreshEvery is how often the board reads the recently closed pull requests, and the Summary tab its history, where the file does not say. Each read costs GitHub about as much as the open one, and what it finds changes only when a pull request closes, which the open read already shows.
const DefaultDiffSectionMaxLines = 300
DefaultDiffSectionMaxLines is DiffSectionMaxLines where the file does not say: about three screens of the side panel, past which nvim's diff, with its file tree, reads faster than scrolling.
const DefaultRefreshEvery = time.Minute
DefaultRefreshEvery is how often the board reads each provider while it is open, where the file does not say. Each GitHub read spends points from the token's hourly GraphQL allowance.
const RegistryVariable = "PRS_REPOS_REGISTRY"
RegistryVariable names the registry for one shell, ahead of the config file.
Variables ¶
var BlockerKinds = []string{Conflicts, Behind, FailingChecks, Draft}
BlockerKinds is every kind of blocker a merge fix can name.
Functions ¶
func ClosedPullRequestsDir ¶ added in v0.15.0
ClosedPullRequestsDir is where the Summary tab and prs summary keep the merged and closed pull requests they count, a SQLite file for each set of repos: closed-pull-requests under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.
func DefaultRegistry ¶
DefaultRegistry is where prs looks for the registry when nothing names one: repos.json under $XDG_DATA_HOME, or ~/.local/share where that is unset.
func FillCommand ¶ added in v0.17.0
FillCommand puts a pull request's fields into a Command, with each of ShellQuotedPlaceholders quoted for the shell. A branch name may hold ; or $, and anyone who can open a pull request names one.
func FillRecap ¶ added in v0.16.0
func FillRecap(argv []string, fields RecapFields) []string
FillRecap is a Show or Write argv with a window's fields in each placeholder.
func FixPlaceholders ¶ added in v0.17.0
func FixPlaceholders() []string
FixPlaceholders are the names a merge fix's Command takes, sorted.
func ListingCacheDir ¶ added in v0.6.0
ListingCacheDir is where the board keeps each provider's last listing, a file for each set of repos it reads, so the next start draws it before any read returns: listings under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.
func MissingPrograms ¶
MissingPrograms is those of programs that are not on PATH.
func Path ¶
Path is the config file's path under $XDG_CONFIG_HOME, or ~/.config where that is unset.
func Placeholders ¶
func Placeholders() []string
Placeholders are the names a window action's Window and Command, and a merge fix's Window, take, sorted.
func RecapPlaceholders ¶ added in v0.16.0
func RecapPlaceholders() []string
RecapPlaceholders are the names FillRecap fills, sorted.
func RecapWritesDir ¶ added in v0.16.0
RecapWritesDir is where the recaps tab keeps each write's output, one file a window, which that window's next write replaces: recap-writes under $XDG_CACHE_HOME/prs, or ~/.cache/prs where that is unset.
func ShellQuotedPlaceholders ¶ added in v0.17.0
func ShellQuotedPlaceholders() []string
ShellQuotedPlaceholders are the names among FixPlaceholders that FillCommand quotes, sorted.
func TUIDisplayFile ¶ added in v0.19.0
TUIDisplayFile is where prs tui keeps the tab last moved to and each tab's display settings: tui-display.json under $XDG_STATE_HOME/prs, or ~/.local/state/prs where that is unset.
Types ¶
type Config ¶
type Config struct {
// File is the path read, whether or not anything was there.
File string
// Exists says the file was there to read.
Exists bool
// Registry is the repo registry's path. Where it is empty, prs reads Owners whole, and
// with no Owners either, the repos the GitHub token's own account holds. ReposFrom is
// the layer that chose.
Registry string
Owners []string
ReposFrom string
// RefreshEvery is how often the board reads each provider again while it is open, and
// RefreshFrom names the layer that set it.
RefreshEvery time.Duration
RefreshFrom string
// ClosedRefreshEvery is how often the board reads the recently closed pull requests
// again, and the Summary tab what changed in the history it counts from.
// ClosedRefreshFrom names the layer that set it.
ClosedRefreshEvery time.Duration
ClosedRefreshFrom string
// DiffSectionMaxLines is the most lines a pull request may change for its document's Diff
// section to show its diff whole. A larger one's section names its size instead.
// DiffSectionFrom names the layer that set it.
DiffSectionMaxLines int
DiffSectionFrom string
// WindowActions are the keys the file adds, each opening a tmux window on a pull request.
WindowActions []WindowAction
// Recaps are the commands the Recaps tab runs, and empty where the file names none.
Recaps Recaps
// WorktreeRoot is where the fix menu adds a worktree to resolve a conflict in, a directory
// for each repo's checkout under it, and WorktreeRootFrom names the layer that set it.
WorktreeRoot string
WorktreeRootFrom string
// MergeFixes are the fixes the file adds to the menu a pull request that cannot merge
// opens, each running its command in a tmux window behind the board.
MergeFixes []MergeFix
}
Config is what the environment and the file say, with each path expanded.
type Fields ¶
type Fields struct {
Number int
Repo string
Slug string
// Path is the repo's checkout, and Worktree the one the menu rebases the head in, where a
// rebase there stopped or waits to be pushed.
Path, Worktree string
// Head and Base are the branch the pull request merges from and the one it merges into.
Head, Base string
// Blocker is the kind from BlockerKinds, and Log the file holding its failing checks' log.
Blocker, Log string
}
Fields are what a Window or Command can name of a pull request. A window action's take the row's alone, and a merge fix's Command the rest as well, each empty where it does not apply.
type MergeFix ¶ added in v0.17.0
type MergeFix struct {
Key string `yaml:"key"`
Label string `yaml:"label"`
Detail string `yaml:"detail"`
// Needs are the programs the command runs, as a window action's are.
Needs []string `yaml:"needs"`
// Blockers are the kinds of blocker the fix is offered for, from BlockerKinds.
Blockers []string `yaml:"blockers"`
// Window is the tmux window's name, which takes the row's placeholders alone, so the board
// can find it open from the row. Command takes FixPlaceholders.
Window string `yaml:"window"`
Command string `yaml:"command"`
// RowReads is what the pull request's row reads while the fix's window is open, and
// "fixing" where the file does not say.
RowReads string `yaml:"row_reads"`
}
MergeFix is a fix the menu of a pull request that cannot merge offers, on its key, for the blockers it names. Its command runs in a new tmux window behind the board, started in the pull request's checkout, and it is offered only where every program it needs is on PATH.
type RecapFields ¶ added in v0.16.0
RecapFields are what a recaps Show or Write can name of a window.
type Recaps ¶ added in v0.16.0
type Recaps struct {
// Needs are the programs the commands run, which an argv starting sh hides. A machine
// missing one shows no Recaps tab.
Needs []string `yaml:"needs"`
List []string `yaml:"list"`
Show []string `yaml:"show"`
Write []string `yaml:"write"`
}
Recaps are the commands the Recaps tab runs, each an argv run with no shell. List prints the windows a recap is written for, in the order the tab draws them, one a line as its kind and its label, and is left as written, so a list run through sh may hold braces. Show prints one window's recap as markdown, and Write writes it, which is a model call. Show and Write take the names RecapPlaceholders lists. Write may be left out, and the tab then has no key that writes.
type WindowAction ¶
type WindowAction struct {
Key string `yaml:"key"`
Label string `yaml:"label"`
Detail string `yaml:"detail"`
// Needs are the programs the command runs, checked before the window opens, because
// tmux reports a window opened even when its command cannot start.
Needs []string `yaml:"needs"`
// Providers limits the key to pull requests these providers host. Empty means any.
Providers []string `yaml:"providers"`
// Window is the tmux window's name, and Command the shell command it runs. Both take
// the names Placeholders lists.
Window string `yaml:"window"`
Command string `yaml:"command"`
// RunsReviewRound says the command runs a Claude review round on the pull request, so the
// row reads the round as running while the window is open and the round has not finished.
RunsReviewRound bool `yaml:"runs_review_round"`
}
WindowAction is a key that runs a command in a new tmux window, started in the pull request's checkout. It is offered only where every program it needs is on PATH.
func (WindowAction) Missing ¶
func (a WindowAction) Missing() []string
Missing is the programs the action needs that are not on PATH. The board offers its key only where none is.