Documentation
¶
Overview ¶
Package changes provides domain types for analyzing commit changes.
Package changes provides domain types for analyzing commit changes.
Package changes provides domain types for analyzing commit changes.
Package changes provides domain types for analyzing commit changes.
Package changes provides domain types for analyzing commit changes.
Index ¶
- Variables
- type Categories
- type ChangeSet
- func (cs *ChangeSet) AddCommit(commit *ConventionalCommit)
- func (cs *ChangeSet) AddCommits(commits []*ConventionalCommit)
- func (cs *ChangeSet) Categories() *Categories
- func (cs *ChangeSet) ChangelogCommits() []*ConventionalCommit
- func (cs *ChangeSet) CommitCount() int
- func (cs *ChangeSet) Commits() []*ConventionalCommit
- func (cs *ChangeSet) CreatedAt() time.Time
- func (cs *ChangeSet) FilterByScope(scope string) *ChangeSet
- func (cs *ChangeSet) FromRef() string
- func (cs *ChangeSet) HasBreakingChanges() bool
- func (cs *ChangeSet) HasFeatures() bool
- func (cs *ChangeSet) HasFixes() bool
- func (cs *ChangeSet) ID() ChangeSetID
- func (cs *ChangeSet) IsEmpty() bool
- func (cs *ChangeSet) ReleaseType() ReleaseType
- func (cs *ChangeSet) Scopes() []string
- func (cs *ChangeSet) SortByDate()
- func (cs *ChangeSet) SortByType()
- func (cs *ChangeSet) Summary() ChangeSetSummary
- func (cs *ChangeSet) ToRef() string
- type ChangeSetID
- type ChangeSetSummary
- type CommitType
- type ConventionalCommit
- func (c *ConventionalCommit) AffectsChangelog() bool
- func (c *ConventionalCommit) Author() string
- func (c *ConventionalCommit) AuthorEmail() string
- func (c *ConventionalCommit) Body() string
- func (c *ConventionalCommit) BreakingMessage() string
- func (c *ConventionalCommit) Date() time.Time
- func (c *ConventionalCommit) Footer() string
- func (c *ConventionalCommit) FormattedSubject() string
- func (c *ConventionalCommit) Hash() string
- func (c *ConventionalCommit) IsBreaking() bool
- func (c *ConventionalCommit) RawMessage() string
- func (c *ConventionalCommit) ReleaseType() ReleaseType
- func (c *ConventionalCommit) Scope() string
- func (c *ConventionalCommit) ShortHash() string
- func (c *ConventionalCommit) String() string
- func (c *ConventionalCommit) Subject() string
- func (c *ConventionalCommit) Type() CommitType
- type ConventionalCommitOption
- func WithAuthor(name, email string) ConventionalCommitOption
- func WithBody(body string) ConventionalCommitOption
- func WithBreaking(msg string) ConventionalCommitOption
- func WithDate(date time.Time) ConventionalCommitOption
- func WithFooter(footer string) ConventionalCommitOption
- func WithRawMessage(msg string) ConventionalCommitOption
- func WithScope(scope string) ConventionalCommitOption
- type ReleaseType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCommitMessage indicates an invalid conventional commit message. ErrInvalidCommitMessage = errors.New("invalid conventional commit message") // ErrEmptyChangeSet indicates an empty changeset. ErrEmptyChangeSet = errors.New("changeset is empty") // ErrNoCommitsFound indicates no commits were found in the specified range. ErrNoCommitsFound = errors.New("no commits found in the specified range") // ErrInvalidCommitType indicates an unrecognized commit type. ErrInvalidCommitType = errors.New("invalid commit type") // ErrInvalidReleaseType indicates an unrecognized release type. ErrInvalidReleaseType = errors.New("invalid release type") )
Domain errors for changes operations.
Functions ¶
This section is empty.
Types ¶
type Categories ¶
type Categories struct {
Features []*ConventionalCommit
Fixes []*ConventionalCommit
Breaking []*ConventionalCommit
Perf []*ConventionalCommit
Docs []*ConventionalCommit
Refactors []*ConventionalCommit
Tests []*ConventionalCommit
Build []*ConventionalCommit
CI []*ConventionalCommit
Chores []*ConventionalCommit
Reverts []*ConventionalCommit
Other []*ConventionalCommit
}
Categories holds commits organized by type.
type ChangeSet ¶
type ChangeSet struct {
// contains filtered or unexported fields
}
ChangeSet is an aggregate root representing a collection of commits that form a potential release.
func NewChangeSet ¶
func NewChangeSet(id ChangeSetID, fromRef, toRef string) *ChangeSet
NewChangeSet creates a new ChangeSet aggregate.
func (*ChangeSet) AddCommit ¶
func (cs *ChangeSet) AddCommit(commit *ConventionalCommit)
AddCommit adds a commit to the changeset. Note: Adding commits after Categories() has been called will not update the categorization. Create a new ChangeSet if you need to add commits after categorization.
func (*ChangeSet) AddCommits ¶
func (cs *ChangeSet) AddCommits(commits []*ConventionalCommit)
AddCommits adds multiple commits to the changeset. Note: Adding commits after Categories() has been called will not update the categorization. Create a new ChangeSet if you need to add commits after categorization.
func (*ChangeSet) Categories ¶
func (cs *ChangeSet) Categories() *Categories
Categories returns commits organized by type. This method is safe for concurrent access and uses sync.Once for efficient initialization. Note: Categorization is done once; adding commits after this is called won't update categories.
func (*ChangeSet) ChangelogCommits ¶
func (cs *ChangeSet) ChangelogCommits() []*ConventionalCommit
ChangelogCommits returns commits that should appear in the changelog. This method is safe for concurrent access.
func (*ChangeSet) CommitCount ¶
CommitCount returns the number of commits. This method is safe for concurrent access.
func (*ChangeSet) Commits ¶
func (cs *ChangeSet) Commits() []*ConventionalCommit
Commits returns all commits in the changeset. This method is safe for concurrent access.
func (*ChangeSet) FilterByScope ¶
FilterByScope returns a new changeset containing only commits with the given scope. This method is safe for concurrent access.
func (*ChangeSet) HasBreakingChanges ¶
HasBreakingChanges returns true if any commit has breaking changes. This method is safe for concurrent access.
func (*ChangeSet) HasFeatures ¶
HasFeatures returns true if any commit adds features. This method is safe for concurrent access.
func (*ChangeSet) HasFixes ¶
HasFixes returns true if any commit fixes bugs. This method is safe for concurrent access.
func (*ChangeSet) IsEmpty ¶
IsEmpty returns true if there are no commits. This method is safe for concurrent access.
func (*ChangeSet) ReleaseType ¶
func (cs *ChangeSet) ReleaseType() ReleaseType
ReleaseType determines the release type based on all commits. This method is safe for concurrent access.
func (*ChangeSet) Scopes ¶
Scopes returns all unique scopes in the changeset. This method is safe for concurrent access.
func (*ChangeSet) SortByDate ¶
func (cs *ChangeSet) SortByDate()
SortByDate sorts commits by date (newest first). Note: Sorting after Categories() has been called will not update the categorization. The order of categories is based on commit properties, not commit order.
func (*ChangeSet) SortByType ¶
func (cs *ChangeSet) SortByType()
SortByType sorts commits by type priority (breaking first, then features, etc.). Note: Sorting after Categories() has been called will not update the categorization. The order of categories is based on commit properties, not commit order.
func (*ChangeSet) Summary ¶
func (cs *ChangeSet) Summary() ChangeSetSummary
Summary returns a summary of the changeset. This method is safe for concurrent access.
type ChangeSetSummary ¶
type ChangeSetSummary struct {
TotalCommits int
Features int
Fixes int
Breaking int
Performance int
Documentation int
Refactoring int
Tests int
Other int
ReleaseType ReleaseType
Scopes []string
}
Summary returns a summary of the changeset.
type CommitType ¶
type CommitType string
CommitType represents the type of a conventional commit.
const ( CommitTypeFeat CommitType = "feat" CommitTypeFix CommitType = "fix" CommitTypeDocs CommitType = "docs" CommitTypeStyle CommitType = "style" CommitTypeRefactor CommitType = "refactor" CommitTypePerf CommitType = "perf" CommitTypeTest CommitType = "test" CommitTypeBuild CommitType = "build" CommitTypeCI CommitType = "ci" CommitTypeChore CommitType = "chore" CommitTypeRevert CommitType = "revert" )
Standard conventional commit types.
func AllCommitTypes ¶
func AllCommitTypes() []CommitType
AllCommitTypes returns all standard commit types.
func ParseCommitType ¶
func ParseCommitType(s string) (CommitType, bool)
ParseCommitType parses a string into a CommitType. Returns the commit type and true if valid, or empty string and false if invalid.
func (CommitType) AffectsChangelog ¶
func (t CommitType) AffectsChangelog() bool
AffectsChangelog returns true if this commit type should appear in changelog.
func (CommitType) ChangelogCategory ¶
func (t CommitType) ChangelogCategory() string
ChangelogCategory returns the changelog category for this commit type.
func (CommitType) Description ¶
func (t CommitType) Description() string
Description returns a human-readable description of the commit type.
func (CommitType) IsValid ¶
func (t CommitType) IsValid() bool
IsValid returns true if the commit type is a recognized type.
func (CommitType) String ¶
func (t CommitType) String() string
String returns the string representation of the commit type.
type ConventionalCommit ¶
type ConventionalCommit struct {
// contains filtered or unexported fields
}
ConventionalCommit represents a parsed conventional commit. This is an entity in DDD terms - it has identity (hash) and state.
func NewConventionalCommit ¶
func NewConventionalCommit(hash string, commitType CommitType, subject string, opts ...ConventionalCommitOption) *ConventionalCommit
NewConventionalCommit creates a new ConventionalCommit entity.
func ParseConventionalCommit ¶
func ParseConventionalCommit(hash, message string, opts ...ConventionalCommitOption) *ConventionalCommit
ParseConventionalCommit parses a commit message into a ConventionalCommit. Returns nil if the message is not a valid conventional commit.
func (*ConventionalCommit) AffectsChangelog ¶
func (c *ConventionalCommit) AffectsChangelog() bool
AffectsChangelog returns true if this commit should appear in changelog.
func (*ConventionalCommit) Author ¶
func (c *ConventionalCommit) Author() string
Author returns the commit author name.
func (*ConventionalCommit) AuthorEmail ¶
func (c *ConventionalCommit) AuthorEmail() string
AuthorEmail returns the commit author email.
func (*ConventionalCommit) Body ¶
func (c *ConventionalCommit) Body() string
Body returns the commit body.
func (*ConventionalCommit) BreakingMessage ¶
func (c *ConventionalCommit) BreakingMessage() string
BreakingMessage returns the breaking change message if any.
func (*ConventionalCommit) Date ¶
func (c *ConventionalCommit) Date() time.Time
Date returns the commit date.
func (*ConventionalCommit) Footer ¶
func (c *ConventionalCommit) Footer() string
Footer returns the commit footer.
func (*ConventionalCommit) FormattedSubject ¶
func (c *ConventionalCommit) FormattedSubject() string
FormattedSubject returns the subject formatted for changelog display.
func (*ConventionalCommit) Hash ¶
func (c *ConventionalCommit) Hash() string
Hash returns the commit hash.
func (*ConventionalCommit) IsBreaking ¶
func (c *ConventionalCommit) IsBreaking() bool
IsBreaking returns true if this is a breaking change.
func (*ConventionalCommit) RawMessage ¶
func (c *ConventionalCommit) RawMessage() string
RawMessage returns the original commit message.
func (*ConventionalCommit) ReleaseType ¶
func (c *ConventionalCommit) ReleaseType() ReleaseType
ReleaseType returns the release type this commit requires.
func (*ConventionalCommit) Scope ¶
func (c *ConventionalCommit) Scope() string
Scope returns the commit scope.
func (*ConventionalCommit) ShortHash ¶
func (c *ConventionalCommit) ShortHash() string
ShortHash returns the short (7 character) commit hash.
func (*ConventionalCommit) String ¶
func (c *ConventionalCommit) String() string
String returns a string representation of the commit.
func (*ConventionalCommit) Subject ¶
func (c *ConventionalCommit) Subject() string
Subject returns the commit subject (description).
func (*ConventionalCommit) Type ¶
func (c *ConventionalCommit) Type() CommitType
Type returns the commit type.
type ConventionalCommitOption ¶
type ConventionalCommitOption func(*ConventionalCommit)
ConventionalCommitOption is a functional option for creating commits.
func WithAuthor ¶
func WithAuthor(name, email string) ConventionalCommitOption
WithAuthor sets the commit author.
func WithBreaking ¶
func WithBreaking(msg string) ConventionalCommitOption
WithBreaking marks the commit as a breaking change.
func WithDate ¶
func WithDate(date time.Time) ConventionalCommitOption
WithDate sets the commit date.
func WithFooter ¶
func WithFooter(footer string) ConventionalCommitOption
WithFooter sets the commit footer.
func WithRawMessage ¶ added in v0.2.0
func WithRawMessage(msg string) ConventionalCommitOption
WithRawMessage sets the original raw commit message.
func WithScope ¶
func WithScope(scope string) ConventionalCommitOption
WithScope sets the commit scope.
type ReleaseType ¶
type ReleaseType string
ReleaseType represents the type of release based on changes.
const ( // ReleaseTypeMajor indicates a major release with breaking changes. ReleaseTypeMajor ReleaseType = "major" // ReleaseTypeMinor indicates a minor release with new features. ReleaseTypeMinor ReleaseType = "minor" // ReleaseTypePatch indicates a patch release with bug fixes. ReleaseTypePatch ReleaseType = "patch" // ReleaseTypeNone indicates no release is needed. ReleaseTypeNone ReleaseType = "none" )
func MaxReleaseType ¶
func MaxReleaseType(a, b ReleaseType) ReleaseType
MaxReleaseType returns the higher precedence release type. Major > Minor > Patch > None
func ParseReleaseType ¶
func ParseReleaseType(s string) (ReleaseType, error)
ParseReleaseType parses a string into a ReleaseType.
func ReleaseTypeFromCommitType ¶
func ReleaseTypeFromCommitType(ct CommitType, isBreaking bool) ReleaseType
ReleaseTypeFromCommitType determines the release type based on commit type.
func (ReleaseType) Description ¶
func (r ReleaseType) Description() string
Description returns a human-readable description.
func (ReleaseType) IsValid ¶
func (r ReleaseType) IsValid() bool
IsValid returns true if the release type is valid.
func (ReleaseType) String ¶
func (r ReleaseType) String() string
String returns the string representation of the release type.
func (ReleaseType) ToBumpType ¶
func (r ReleaseType) ToBumpType() version.BumpType
ToBumpType converts a ReleaseType to a version.BumpType.