settings

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package settings holds the few choices that belong to a person rather than to a board.

It exists because two of them arrived with the ticket refs: which remote the refs go to, and whether an assignment pops up a desktop notification. Neither belongs in the repository — one teammate wanting to be notified says nothing about another, and a remote name is a property of a clone, not of the project.

The file is ~/.jaira/settings.json, beside projects.json, and every field has a working default: a missing file, an unreadable one and an empty one all mean "the defaults", because settings a user never opened must never be the reason a board does not start.

Index

Constants

View Source
const DefaultLandingGrace = 3 * 24 * time.Hour

DefaultLandingGrace is how long a finished ticket may take to arrive before it is worth mentioning.

Three days, chosen against how long a review actually takes here rather than as a round number: a week is long enough that a forgotten branch stops being news by the time anybody hears about it.

Variables

This section is empty.

Functions

func Path

func Path() string

Path is the settings file, honouring JAIRA_HOME so tests and a sandboxed run do not touch the real one.

func Save

func Save(s Settings) error

Save writes the settings, creating ~/.jaira if it is not there yet.

Types

type Settings

type Settings struct {
	// Remote is where ticket refs are pushed and fetched. Empty means origin.
	Remote string `json:"remote,omitempty"`

	// Notify turns the desktop notification for an assignment off. It is
	// phrased as the negative so that the zero value — a file that does not
	// mention it, or no file at all — leaves notifications on: the feature was
	// asked for, and a default that silently withholds it would answer the
	// request with nothing.
	NotifyOff bool `json:"notify-off,omitempty"`

	// Hook is a script called when a ticket moves or is claimed, for immediate
	// delivery through whatever the user already uses (a Slack webhook,
	// ntfy.sh, Telegram). jaira only calls it and brings no dependency of its
	// own; an empty value calls nothing.
	Hook string `json:"hook,omitempty"`

	// LandingBranches are the branches whose contents mean a ticket has
	// arrived: filed away in one of them, it is finished for everybody and its
	// ref has done its job.
	//
	// A list with globs rather than one "main branch", because there is no
	// answer to what the important branch is called — main, master, develop, a
	// release line — and a list turns a guess into a setting. Empty falls back
	// to the remote's own HEAD, and if that cannot be resolved either, nothing
	// is ever removed.
	LandingBranches []string `json:"landing-branches,omitempty"`

	// SnapshotBranch holds the board as files, as a backup for whoever clones
	// for the first time and has no refs yet. Empty means jaira/board.
	SnapshotBranch string `json:"snapshot-branch,omitempty"`

	// SnapshotEvery is how old the backup may get, as a duration ("72h").
	// Empty means three days: every participant's clone holds the refs, so the
	// board survives any one machine, and this is for the slow cases only.
	SnapshotEvery string `json:"snapshot-every,omitempty"`

	// FetchEvery is how often the ticket refs are brought up to date in the
	// background, as a duration ("10m"). Empty means ten minutes.
	//
	// One setting for the CLI and the board alike. They used to disagree — the
	// board had its own hard-wired minute — and somebody who changed this would
	// have found the board carrying on at its own pace.
	FetchEvery string `json:"fetch-every,omitempty"`

	// LandingGrace is how long a finished ticket may go without arriving in a
	// landing branch before jaira mentions it, as a duration ("72h"). Empty
	// means three days.
	LandingGrace string `json:"landing-grace,omitempty"`
}

Settings is the whole file.

func Load

func Load() Settings

Load returns the settings, or the defaults for anything missing.

An unreadable or malformed file is deliberately not an error: it is one person's preferences, and refusing to open a board over it would trade a small annoyance for a total one.

func (Settings) FetchInterval

func (s Settings) FetchInterval() time.Duration

FetchInterval returns how often the refs are refreshed in the background, for the CLI and the board alike.

func (Settings) Landing

func (s Settings) Landing(remote string, remoteHead func() string) []string

Landing returns the branches to check for a landed ticket, as revisions on the remote.

The configured list wins over the remote's HEAD, and that order matters: the HEAD is the hosting provider's default, not necessarily the branch a team cares about. Both are prefixed with the remote, since what counts is what has arrived where everybody can see it — not what has landed in somebody's local copy of a branch.

func (Settings) LandingGraceInterval

func (s Settings) LandingGraceInterval() time.Duration

LandingGraceInterval returns that, or whatever the settings say instead.

func (Settings) NotifyEnabled

func (s Settings) NotifyEnabled() bool

NotifyEnabled reports whether an assignment should raise a desktop notification.

func (Settings) RemoteName

func (s Settings) RemoteName() string

RemoteOr returns the configured remote, or the default.

func (Settings) SnapshotBranchName

func (s Settings) SnapshotBranchName() string

SnapshotBranchName returns the configured snapshot branch, or the default.

func (Settings) SnapshotInterval

func (s Settings) SnapshotInterval() time.Duration

SnapshotInterval returns how old a snapshot may get.

Jump to

Keyboard shortcuts

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