commitparser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNoCommitsSinceTag = "no commits since last tag"
	ErrNoVCSDetected     = "not in a version control repository"
	ErrNoBumpDetected    = "no version bump detected in commits"
)

Error messages

View Source
const (
	LogCommitsAnalyzed   = "commits_analyzed"
	LogBumpLevelDetected = "bump_level_detected"
	LogSkipDetected      = "skip_detected"
)

Log messages

Variables

This section is empty.

Functions

This section is empty.

Types

type BumpLevel

type BumpLevel int

BumpLevel represents the detected version bump level

const (
	BumpNone  BumpLevel = iota // No bump detected
	BumpPatch                  // Patch bump (fix:, +semver:patch)
	BumpMinor                  // Minor bump (feat:, +semver:minor)
	BumpMajor                  // Major bump (BREAKING CHANGE, !, +semver:major)
	BumpSkip                   // Explicitly skip versioning (+semver:skip)
)

func (BumpLevel) String

func (b BumpLevel) String() string

String returns the string representation of a BumpLevel

func (BumpLevel) ToVersionLevel

func (b BumpLevel) ToVersionLevel() version.VersionLevel

ToVersionLevel converts BumpLevel to version.VersionLevel Returns -1 for BumpNone and BumpSkip (no version change)

type CommitAnalysis

type CommitAnalysis struct {
	BumpLevel        BumpLevel      // Final determined bump level
	Commits          []ParsedCommit // All parsed commits
	SkipReason       string         // If skip, why
	TriggeringCommit string         // The commit that determined the bump level
	CommitCount      int            // Total commits analyzed
}

CommitAnalysis contains the result of analyzing multiple commits

type ParseMode

type ParseMode int

ParseMode controls which commit formats to recognize

const (
	ModeSemverMarkers       ParseMode = 1 << iota // +semver: markers only
	ModeConventionalCommits                       // Conventional commits only
	ModeAll                 = ModeSemverMarkers | ModeConventionalCommits
)

type ParsedCommit

type ParsedCommit struct {
	Message    string    // Original commit message
	BumpLevel  BumpLevel // Detected bump level
	Format     string    // "semver-marker", "conventional", or "unknown"
	Type       string    // For conventional: "feat", "fix", etc.
	Scope      string    // For conventional: optional scope in parentheses
	IsBreaking bool      // Whether this is a breaking change
}

ParsedCommit represents a single parsed commit

type Parser

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

Parser handles commit message parsing

func NewParser

func NewParser(mode ParseMode) *Parser

NewParser creates a parser with the specified mode

func (*Parser) AnalyzeCommits

func (p *Parser) AnalyzeCommits(messages []string) CommitAnalysis

AnalyzeCommits analyzes multiple commits and determines the bump level Conflict resolution:

  • Highest level wins (major > minor > patch > none)
  • Exception: if ANY commit has +semver:skip, return skip

func (*Parser) ParseCommit

func (p *Parser) ParseCommit(message string) ParsedCommit

ParseCommit parses a single commit message and detects bump level

Jump to

Keyboard shortcuts

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