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 ¶
const FileName = ".preen.toml"
FileName is the config file preen looks for at the repository root.
Variables ¶
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.
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.