commit

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamEmojiHardWindow  = "emoji_hard_window"
	ParamEmojiSoftWindow  = "emoji_soft_window"
	ParamEmojiSuggestions = "emoji_suggestions"
)

Param keys the pipeline projects config.EmojiConfig's fields onto (see internal/analysis.withEmojiParams), read back by merge below - the one place each name is spelled, instead of a string literal on both ends of the config-to-param hop.

View Source
const AnalyzerID = "commit-lint"

AnalyzerID is the stable ID this analyzer reports findings under, and the key its runtime params are looked up by - exported so the config projection in internal/analysis.withEmojiParams spells it once.

Variables

This section is empty.

Functions

func Validate

func Validate(msg commitmsg.Message, cfg RuleConfig, reporters ruleReporters) []core.Finding

Validate checks a parsed commit message against all rules and returns findings. Special cases (initial commit, merge, WIP) are exempt from type/emoji requirements. reporters carries the 14 sub-rule reporters, already resolved against the run's config (see ruleReporters.resolved).

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

Analyzer implements core.Analyzer. It parses a commit message from the pipeline context, validates it against all commit rules (format, emoji catalog, repetition window, tool-attribution trailers), and returns findings.

func NewAnalyzer

func NewAnalyzer(catalog *emoji.Catalog) *Analyzer

NewAnalyzer creates an Analyzer with default rule and window configs, validating against the given emoji catalog.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx *core.AnalysisContext) []core.Finding

Analyze parses the commit message from ctx.CommitMsg, validates it, and returns findings.

func (*Analyzer) ID

func (a *Analyzer) ID() string

func (*Analyzer) Stage

func (a *Analyzer) Stage() core.StageID

type EmojiCheck

type EmojiCheck struct {
	Message   commitmsg.Message
	Catalog   *emoji.Catalog
	History   []string
	Config    EmojiWindowConfig
	Reporters emojiReporters
}

EmojiCheck is one commit message weighed against the catalog and the recent history. History holds recent commit subjects OLDEST FIRST, as git log yields them once reversed. Reporters carries the 4 sub-rule reporters, already resolved against the run's config (see emojiReporters.resolved).

func (EmojiCheck) ValidateEmoji

func (check EmojiCheck) ValidateEmoji() []core.Finding

ValidateEmoji reports every emoji rule the commit breaks: membership of the catalog, the ban list, and repetition against recent history.

type EmojiWindowConfig

type EmojiWindowConfig struct {
	// HardWindow is how many preceding commits an emoji may not repeat
	// within. A violation blocks the commit.
	HardWindow int
	// SoftWindow is the wider span that only earns advice. A repeat past
	// HardWindow but inside it is reported as information.
	SoftWindow int
	// Suggestions is how many alternatives a finding offers.
	Suggestions int
}

EmojiWindowConfig holds the repetition windows and the size of the suggestion set offered when a rule is broken.

func DefaultEmojiWindowConfig

func DefaultEmojiWindowConfig() EmojiWindowConfig

type RuleConfig

type RuleConfig struct {
	// MaxSubjectLen is the maximum subject line length. Default: 72.
	MaxSubjectLen int
	// MaxBodyLineLen is the maximum body line length. Default: 100.
	MaxBodyLineLen int
	// MaxBodyLen is the maximum total body length in runes. Default: 150.
	MaxBodyLen int
	// RequireEmoji controls whether a leading emoji is required.
	RequireEmoji bool
	// RejectToolTrailers controls whether tool-attribution trailers
	// (Co-Authored-By, Claude-Session, ...) are rejected.
	RejectToolTrailers bool
}

RuleConfig holds the configurable thresholds for commit validation.

func DefaultRuleConfig

func DefaultRuleConfig() RuleConfig

DefaultRuleConfig returns the default commit validation thresholds.

Jump to

Keyboard shortcuts

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