commitmsg

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: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLeadingEmojis = 3

MaxLeadingEmojis is the most leading :shortcode: emoji a commit message may carry. The parser consumes every leading emoji token, however many there are; the commit rules (see internal/analyzer/commit) reject a message whose Emojis exceeds this count.

Variables

View Source
var AllowedTypes = []string{
	"feat", "fix", "refactor", "chore", "docs",
	"test", "perf", "build", "ci", "style", "revert",
}

AllowedTypes are the Conventional Commit types recognized by the linter.

Functions

This section is empty.

Types

type Footer struct {
	// Key is the trailer token (e.g. "Closes", "Refs", "Co-Authored-By").
	Key string
	// Value is the trailer value text.
	Value string
}

Footer is a key-value trailer at the end of the commit body.

type Message

type Message struct {
	// Emojis are the leading :shortcode: tokens (1-3 allowed).
	Emojis []string
	// Type is the Conventional Commit type (feat, fix, etc.).
	Type string
	// Scope is the optional parenthesized scope, without parens.
	Scope string
	// Breaking is true when the subject carries the ! marker.
	Breaking bool
	// Description is the subject text after "type(scope)!: ".
	Description string
	// Body is the optional text after the subject, separated by a blank line.
	Body string
	// Footers are the key-value trailers at the end (e.g. "Closes: #42").
	Footers []Footer
	// IsMerge is true for ":volcano: Merge ..." messages (no type required).
	IsMerge bool
	// IsInitial is true for ":ghost: Initial Commit" messages (no type required).
	IsInitial bool
	// IsWIP is true when the description starts with [wip] or [WIP].
	IsWIP bool
	// Raw is the original input message.
	Raw string
}

Message is the structured representation of a parsed commit message. The parser fills these fields by consuming the raw message rune by rune.

func Parse

func Parse(raw string) Message

Parse parses a raw commit message into a Message. It is lenient: parse errors are recorded but the message is still returned with whatever fields could be extracted. The caller validates via the rules package.

func (Message) ToolTrailer

func (m Message) ToolTrailer() string

ToolTrailer returns the first tool-attribution signal found in the message (a forbidden trailer key or an attribution marker anywhere in the raw text), or "" when the message carries none.

Jump to

Keyboard shortcuts

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