commit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Breaking = iota
	Minor
	Patch
	Uncategorized
)

Variables

View Source
var ErrFooterCaps = errors.New("BREAKING CHANGE token must be capitalized")
View Source
var ErrFooterSep = errors.New("BREAKING CHANGE must be followed by a colon and space (: )")

Functions

func ApplyPolicy

func ApplyPolicy(commits []*Commit, cfg *config.Config) error

func ErrBlankLine

func ErrBlankLine(id string) error

func ErrDescriptionLength

func ErrDescriptionLength(id string, min int, max int) error

func ErrEmpty

func ErrEmpty(id string) error

func ErrPolicy

func ErrPolicy(id string, msg string) error

func ErrRequiredFooters

func ErrRequiredFooters(id string, tokens util.CaseInsensitiveSet) error

func ErrRequiredScope

func ErrRequiredScope(id string) error

func ErrSummary

func ErrSummary(id string) error

func ErrSyntax

func ErrSyntax(id string, msg string) error

func ErrUnrecognizedFooter

func ErrUnrecognizedFooter(id string, token string) error

func ErrUnrecognizedScope

func ErrUnrecognizedScope(id string) error

func ErrUnrecognizedType

func ErrUnrecognizedType(id string) error

func IterRange

func IterRange(repoPath string, rangeSpec string, cfg *config.Config, f func(*Commit, error) bool) error

IterRange parses all of the commit messages in the range. For each commit, it invokes the callback function with the parsed Commit object, or an error if the commit did not obey the Conventional Commits standard. The callback function can abort the iteration by returning false.

func StripComments added in v0.2.0

func StripComments(msg string) string

StripComments removes all lines that start with "#" from the input, and returns the resulting string.

Types

type Commit

type Commit struct {
	Id          string
	ShortId     string
	Type        string
	Scope       string
	IsExclaimed bool
	Description string
	Body        string
	Footers     []Footer
	IsBreaking  bool
}

Commit represents a single conventional commit.

func NewCommit

func NewCommit(id string) *Commit

func ParseMessage added in v0.2.0

func ParseMessage(msg string, cfg *config.Config) ([]*Commit, error)

ParseMessage parses a single commit message and returns a slice of the resulting Commit objects. (It may return an empty slice if the commit message was excluded.)

func ParseRange

func ParseRange(repoPath string, rangeSpec string, cfg *config.Config) ([]*Commit, error)

ParseRange parses all of the commit messages in the range and returns a slice of the resulting Commit objects. If an error occurs, the slice may contain a partial set of all the commits that were successfully processed so far.

func (*Commit) ApplyPolicy

func (c *Commit) ApplyPolicy(cfg *config.Config) error

ApplyPolicy checks if the commit is semantically valid according to the supplied policy object.

func (*Commit) Classification

func (c *Commit) Classification(cfg *config.Config) int

func (*Commit) Summary

func (c *Commit) Summary() string

Summary returns a one-line summary of the commit, in the format "type(scope)!: description".

type Footer struct {
	// Token is a word without whitespace, except for the special
	// "BREAKING CHANGE" token.
	Token string

	// Separator is either ": " or " #". It is not important when looking up
	// footers, but saving it allows us to reconstruct the original commit
	// message from this object.
	Separator string

	// Value is the text corresponding to the token. It may contain spaces
	// and newlines.
	Value string
}

Footer is a "token: value" or "token #value" pair.

func (*Footer) IsBreakingChange

func (f *Footer) IsBreakingChange() (bool, error)

IsBreakingChange checks whether this footer designates a breaking change. It returns an error if the breaking change footer is not formatted correctly according to the standard.

type ParseError

type ParseError struct {
	Errors []string
}

func NewParseError

func NewParseError() *ParseError

func (*ParseError) Append

func (e *ParseError) Append(err error)

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) HasErrors

func (e *ParseError) HasErrors() bool

Jump to

Keyboard shortcuts

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