conventionalcommit

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 4 Imported by: ? modules, 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 conventionalcommit provides parsing and validation for conventional commit messages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidFormat indicates the commit message doesn't match conventional format.
	ErrInvalidFormat = errors.New("invalid conventional commit format")
	// ErrEmptyMessage indicates the commit message is empty.
	ErrEmptyMessage = errors.New("empty commit message")
)

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Type        string
	Scope       string
	Description string
	Body        string
	Footer      string
	Raw         string
	TicketRefs  []TicketRef
	Breaking    bool
}

Commit represents a parsed conventional commit message.

func (*Commit) Format

func (c *Commit) Format() string

Format formats a Commit back to conventional commit format.

func (*Commit) GetJIRATickets

func (c *Commit) GetJIRATickets() []TicketRef

GetJIRATickets returns all JIRA ticket references.

func (*Commit) HasJIRATicket

func (c *Commit) HasJIRATicket() bool

HasJIRATicket returns true if the commit has JIRA ticket references.

func (*Commit) HasTicketRefs

func (c *Commit) HasTicketRefs() bool

HasTicketRefs returns true if the commit has any ticket references.

func (*Commit) Header

func (c *Commit) Header() string

Header returns the first line of the commit message.

type Parser

type Parser struct {
	// StrictMode enforces strict conventional commit format.
	StrictMode bool
	// AllowEmptyScope permits commits without scope.
	AllowEmptyScope bool
}

Parser provides conventional commit parsing with configurable options.

func DefaultParser

func DefaultParser() *Parser

DefaultParser returns a parser with default settings.

func (*Parser) Parse

func (p *Parser) Parse(message string) (*Commit, error)

Parse parses a commit message into a Commit struct.

type TicketRef

type TicketRef struct {
	Type string // e.g., "JIRA", "GITHUB", "LINEAR"
	ID   string // e.g., "PROJ-123", "#456", "ABC-789"
	Raw  string // Original reference as found in commit
}

TicketRef represents a ticket reference (e.g., JIRA ticket).

Jump to

Keyboard shortcuts

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