config

package
v2.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 7 Imported by: 1 module, 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 config reads a repository's .preen.toml, which holds the defaults a project wants every preen run to use.

Precedence is the usual one: a flag on the invocation beats the file, and the file beats the built-in defaults. Consent to rewrite published history is deliberately not settable here, since that has to be granted per run.

Index

Constants

View Source
const FileName = ".preen.toml"

FileName is the config file preen looks for at the repository root.

Variables

View Source
var (
	// ErrRead reports a config file that exists but could not be read.
	ErrRead = errors.New("cannot read the config file")
	// ErrParse reports a config file that is not valid TOML, or that holds a
	// value preen cannot act on.
	ErrParse = errors.New("cannot parse the config file")
)

Sentinel errors for reading the repository config.

Functions

This section is empty.

Types

type CommitSection

type CommitSection struct {
	// NoEmDash forbids em and en dashes.
	NoEmDash bool `toml:"no-emdash"`
	// NoSemicolon forbids semicolons.
	NoSemicolon bool `toml:"no-semicolon"`
	// NoHyphen forbids hyphens.
	NoHyphen bool `toml:"no-hyphen"`
	// MaxSubject caps the subject length.
	MaxSubject int `toml:"max-subject"`
	// Punctuation is auto, always, or never.
	Punctuation string `toml:"punctuation"`
	// LowerSubject lowercases the subject's first letter.
	LowerSubject bool `toml:"lower-subject"`
	// Conventional shapes subjects as Conventional Commits.
	Conventional bool `toml:"conventional"`
	// Prefix is prepended to every subject.
	Prefix string `toml:"prefix"`
	// SignOff adds a Signed-off-by trailer.
	SignOff bool `toml:"sign-off"`
	// Body is auto, always, or never.
	Body string `toml:"body"`
	// IncludeFiles lists the touched paths in each body.
	IncludeFiles bool `toml:"include-files"`
	// IncludeLineNumbers cites changed line ranges in each body.
	IncludeLineNumbers bool `toml:"include-line-numbers"`
}

CommitSection is the message style expressed in file form, using the same names as the flags without their leading dashes.

type Config

type Config struct {
	// Commit holds the message style defaults.
	Commit CommitSection `toml:"commit"`
	// Run holds the behavior defaults.
	Run RunSection `toml:"run"`
	// Protect names branches that must never be rewritten.
	Protect ProtectSection `toml:"protect"`
	// Generated tunes which paths preen refuses to commit as generated output.
	Generated GeneratedSection `toml:"generated"`
}

Config is a repository's preen defaults.

func Load

func Load(root string) (Config, error)

Load reads the config from the repository root. A missing file is not an error: it returns the zero config, which is the built-in default.

func (Config) Style

func (c Config) Style() style.Style

Style returns the message style the file configures.

type GeneratedSection

type GeneratedSection struct {
	// AllowAll commits generated output like any other change, which turns the
	// check off for the whole repository.
	AllowAll bool `toml:"allow-all"`
	// Patterns are extra never-commit patterns.
	Patterns []string `toml:"patterns"`
	// Allow are paths this repository commits deliberately, exempted from the
	// patterns that would otherwise catch them.
	Allow []string `toml:"allow"`
}

GeneratedSection tunes the never-commit patterns for one repository.

The defaults cover the caches and build output every project produces, and this section is how a project that keeps one of those paths on purpose says so, or adds a pattern of its own.

type ProtectSection

type ProtectSection struct {
	// Branches are branch names or glob patterns.
	Branches []string `toml:"branches"`
}

ProtectSection names branches preen must refuse to rewrite.

type RunSection

type RunSection struct {
	// Gate is a command run after each commit.
	Gate string `toml:"gate"`
	// AllowNoVerify is standing consent to bypass commit hooks, written into
	// the repository ahead of time so a hook-blocked project can still preen.
	AllowNoVerify bool `toml:"allow-no-verify"`
	// Sweep reports debug prints and other leftovers on every run.
	Sweep bool `toml:"sweep"`
}

RunSection is the behavior defaults.

Jump to

Keyboard shortcuts

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