sv

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReleaseNotesSectionTypeCommits ReleaseNotesSectionConfig.SectionType value.
	ReleaseNotesSectionTypeCommits = "commits"
	// ReleaseNotesSectionTypeBreakingChanges ReleaseNotesSectionConfig.SectionType value.
	ReleaseNotesSectionTypeBreakingChanges = "breaking-changes"
)

Variables

This section is empty.

Functions

func IsValidVersion added in v2.6.0

func IsValidVersion(value string) bool

IsValidVersion return true when a version is valid.

func ToVersion

func ToVersion(value string) (*semver.Version, error)

ToVersion parse string to semver.Version.

Types

type BranchesConfig

type BranchesConfig struct {
	Prefix       string   `yaml:"prefix"`
	Suffix       string   `yaml:"suffix"`
	DisableIssue bool     `yaml:"disable-issue"`
	Skip         []string `yaml:"skip,flow"`
	SkipDetached *bool    `yaml:"skip-detached"`
}

BranchesConfig branches preferences.

type CommitMessage

type CommitMessage struct {
	Type             string            `json:"type,omitempty"`
	Scope            string            `json:"scope,omitempty"`
	Description      string            `json:"description,omitempty"`
	Body             string            `json:"body,omitempty"`
	IsBreakingChange bool              `json:"isBreakingChange,omitempty"`
	Metadata         map[string]string `json:"metadata,omitempty"`
}

CommitMessage is a message using conventional commits.

func NewCommitMessage

func NewCommitMessage(ctype, scope, description, body, issue, breakingChanges string) CommitMessage

NewCommitMessage commit message constructor.

func (CommitMessage) BreakingMessage

func (m CommitMessage) BreakingMessage() string

BreakingMessage return breaking change message from metadata.

func (CommitMessage) Issue

func (m CommitMessage) Issue() string

Issue return issue from metadata.

type CommitMessageConfig

type CommitMessageConfig struct {
	Types          []string                             `yaml:"types,flow"`
	HeaderSelector string                               `yaml:"header-selector"`
	Scope          CommitMessageScopeConfig             `yaml:"scope"`
	Footer         map[string]CommitMessageFooterConfig `yaml:"footer"`
	Issue          CommitMessageIssueConfig             `yaml:"issue"`
}

CommitMessageConfig config a commit message.

func (CommitMessageConfig) IssueFooterConfig

func (c CommitMessageConfig) IssueFooterConfig() CommitMessageFooterConfig

IssueFooterConfig config for issue.

type CommitMessageFooterConfig

type CommitMessageFooterConfig struct {
	Key            string   `yaml:"key"`
	KeySynonyms    []string `yaml:"key-synonyms,flow"`
	UseHash        bool     `yaml:"use-hash"`
	AddValuePrefix string   `yaml:"add-value-prefix"`
}

CommitMessageFooterConfig config footer metadata.

type CommitMessageIssueConfig

type CommitMessageIssueConfig struct {
	Regex string `yaml:"regex"`
}

CommitMessageIssueConfig issue preferences.

type CommitMessageScopeConfig

type CommitMessageScopeConfig struct {
	Values []string `yaml:"values"`
}

CommitMessageScopeConfig config scope preferences.

type Git

type Git interface {
	LastTag() string
	Log(lr LogRange) ([]GitCommitLog, error)
	Commit(header, body, footer string) error
	Tag(version semver.Version) (string, error)
	Tags() ([]GitTag, error)
	Branch() string
	IsDetached() (bool, error)
}

Git commands.

type GitCommitLog

type GitCommitLog struct {
	Date       string        `json:"date,omitempty"`
	Timestamp  int           `json:"timestamp,omitempty"`
	AuthorName string        `json:"authorName,omitempty"`
	Hash       string        `json:"hash,omitempty"`
	Message    CommitMessage `json:"message,omitempty"`
}

GitCommitLog description of a single commit log.

type GitImpl

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

GitImpl git command implementation.

func NewGit

func NewGit(messageProcessor MessageProcessor, cfg TagConfig) *GitImpl

NewGit constructor.

func (GitImpl) Branch

func (GitImpl) Branch() string

Branch get git branch.

func (GitImpl) Commit

func (g GitImpl) Commit(header, body, footer string) error

Commit runs git commit.

func (GitImpl) IsDetached

func (GitImpl) IsDetached() (bool, error)

IsDetached check if is detached.

func (GitImpl) LastTag

func (g GitImpl) LastTag() string

LastTag get last tag, if no tag found, return empty.

func (GitImpl) Log

func (g GitImpl) Log(lr LogRange) ([]GitCommitLog, error)

Log return git log.

func (GitImpl) Tag

func (g GitImpl) Tag(version semver.Version) (string, error)

Tag create a git tag.

func (GitImpl) Tags

func (g GitImpl) Tags() ([]GitTag, error)

Tags list repository tags.

type GitTag

type GitTag struct {
	Name string
	Date time.Time
}

GitTag git tag info.

type LogRange

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

LogRange git log range.

func NewLogRange

func NewLogRange(t LogRangeType, start, end string) LogRange

NewLogRange LogRange constructor.

type LogRangeType

type LogRangeType string

LogRangeType type of log range.

const (
	TagRange  LogRangeType = "tag"
	DateRange LogRangeType = "date"
	HashRange LogRangeType = "hash"
)

constants for log range type.

type MessageProcessor

type MessageProcessor interface {
	SkipBranch(branch string, detached bool) bool
	Validate(message string) error
	ValidateType(ctype string) error
	ValidateScope(scope string) error
	ValidateDescription(description string) error
	Enhance(branch string, message string) (string, error)
	IssueID(branch string) (string, error)
	Format(msg CommitMessage) (string, string, string)
	Parse(subject, body string) (CommitMessage, error)
}

MessageProcessor interface.

type MessageProcessorImpl

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

MessageProcessorImpl process validate message hook.

func NewMessageProcessor

func NewMessageProcessor(mcfg CommitMessageConfig, bcfg BranchesConfig) *MessageProcessorImpl

NewMessageProcessor MessageProcessorImpl constructor.

func (MessageProcessorImpl) Enhance

func (p MessageProcessorImpl) Enhance(branch string, message string) (string, error)

Enhance add metadata on commit message.

func (MessageProcessorImpl) Format

Format a commit message returning header, body and footer.

func (MessageProcessorImpl) IssueID

func (p MessageProcessorImpl) IssueID(branch string) (string, error)

IssueID try to extract issue id from branch, return empty if not found.

func (MessageProcessorImpl) Parse

func (p MessageProcessorImpl) Parse(subject, body string) (CommitMessage, error)

Parse a commit message.

func (MessageProcessorImpl) SkipBranch

func (p MessageProcessorImpl) SkipBranch(branch string, detached bool) bool

SkipBranch check if branch should be ignored.

func (MessageProcessorImpl) Validate

func (p MessageProcessorImpl) Validate(message string) error

Validate commit message.

func (MessageProcessorImpl) ValidateDescription

func (p MessageProcessorImpl) ValidateDescription(description string) error

ValidateDescription check if commit description is valid.

func (MessageProcessorImpl) ValidateScope

func (p MessageProcessorImpl) ValidateScope(scope string) error

ValidateScope check if commit scope is valid.

func (MessageProcessorImpl) ValidateType

func (p MessageProcessorImpl) ValidateType(ctype string) error

ValidateType check if commit type is valid.

type OutputFormatter

type OutputFormatter interface {
	FormatReleaseNote(releasenote ReleaseNote) (string, error)
	FormatChangelog(releasenotes []ReleaseNote) (string, error)
}

OutputFormatter output formatter interface.

type OutputFormatterImpl

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

OutputFormatterImpl formater for release note and changelog.

func NewOutputFormatter

func NewOutputFormatter(templatesFS fs.FS) *OutputFormatterImpl

NewOutputFormatter TemplateProcessor constructor.

func (OutputFormatterImpl) FormatChangelog

func (p OutputFormatterImpl) FormatChangelog(releasenotes []ReleaseNote) (string, error)

FormatChangelog format a changelog.

func (OutputFormatterImpl) FormatReleaseNote

func (p OutputFormatterImpl) FormatReleaseNote(releasenote ReleaseNote) (string, error)

FormatReleaseNote format a release note.

type ReleaseNote

type ReleaseNote struct {
	Version      *semver.Version
	Tag          string
	Date         time.Time
	Sections     []ReleaseNoteSection
	AuthorsNames map[string]struct{}
}

ReleaseNote release note.

type ReleaseNoteBreakingChangeSection added in v2.7.0

type ReleaseNoteBreakingChangeSection struct {
	Name     string
	Messages []string
}

ReleaseNoteBreakingChangeSection breaking change section.

func (ReleaseNoteBreakingChangeSection) SectionName added in v2.7.0

func (s ReleaseNoteBreakingChangeSection) SectionName() string

SectionName section name.

func (ReleaseNoteBreakingChangeSection) SectionType added in v2.7.0

SectionType section type.

type ReleaseNoteCommitsSection added in v2.7.0

type ReleaseNoteCommitsSection struct {
	Name  string
	Types []string
	Items []GitCommitLog
}

ReleaseNoteCommitsSection release note section.

func (ReleaseNoteCommitsSection) HasMultipleTypes added in v2.7.0

func (s ReleaseNoteCommitsSection) HasMultipleTypes() bool

HasMultipleTypes return true if has more than one commit type.

func (ReleaseNoteCommitsSection) SectionName added in v2.7.0

func (s ReleaseNoteCommitsSection) SectionName() string

SectionName section name.

func (ReleaseNoteCommitsSection) SectionType added in v2.7.0

func (ReleaseNoteCommitsSection) SectionType() string

SectionType section type.

type ReleaseNoteProcessor

type ReleaseNoteProcessor interface {
	Create(version *semver.Version, tag string, date time.Time, commits []GitCommitLog) ReleaseNote
}

ReleaseNoteProcessor release note processor interface.

type ReleaseNoteProcessorImpl

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

ReleaseNoteProcessorImpl release note based on commit log.

func NewReleaseNoteProcessor

func NewReleaseNoteProcessor(cfg ReleaseNotesConfig) *ReleaseNoteProcessorImpl

NewReleaseNoteProcessor ReleaseNoteProcessor constructor.

func (ReleaseNoteProcessorImpl) Create

func (p ReleaseNoteProcessorImpl) Create(version *semver.Version, tag string, date time.Time, commits []GitCommitLog) ReleaseNote

Create create a release note based on commits.

type ReleaseNoteSection

type ReleaseNoteSection interface {
	SectionType() string
	SectionName() string
}

ReleaseNoteSection section in release notes.

type ReleaseNotesConfig

type ReleaseNotesConfig struct {
	Headers  map[string]string           `yaml:"headers,omitempty"`
	Sections []ReleaseNotesSectionConfig `yaml:"sections"`
}

ReleaseNotesConfig release notes preferences.

type ReleaseNotesSectionConfig added in v2.7.0

type ReleaseNotesSectionConfig struct {
	Name        string   `yaml:"name"`
	SectionType string   `yaml:"section-type"`
	CommitTypes []string `yaml:"commit-types,flow,omitempty"`
}

ReleaseNotesSectionConfig preferences for a single section on release notes.

type SemVerCommitsProcessor

type SemVerCommitsProcessor interface {
	NextVersion(version *semver.Version, commits []GitCommitLog) (*semver.Version, bool)
}

SemVerCommitsProcessor interface.

type SemVerCommitsProcessorImpl

type SemVerCommitsProcessorImpl struct {
	MajorVersionTypes         map[string]struct{}
	MinorVersionTypes         map[string]struct{}
	PatchVersionTypes         map[string]struct{}
	KnownTypes                []string
	IncludeUnknownTypeAsPatch bool
}

SemVerCommitsProcessorImpl process versions using commit log.

func NewSemVerCommitsProcessor

func NewSemVerCommitsProcessor(vcfg VersioningConfig, mcfg CommitMessageConfig) *SemVerCommitsProcessorImpl

NewSemVerCommitsProcessor SemanticVersionCommitsProcessorImpl constructor.

func (SemVerCommitsProcessorImpl) NextVersion

func (p SemVerCommitsProcessorImpl) NextVersion(version *semver.Version, commits []GitCommitLog) (*semver.Version, bool)

NextVersion calculates next version based on commit log.

type TagConfig

type TagConfig struct {
	Pattern *string `yaml:"pattern"`
	Filter  *string `yaml:"filter"`
}

TagConfig tag preferences.

type VersioningConfig

type VersioningConfig struct {
	UpdateMajor   []string `yaml:"update-major,flow"`
	UpdateMinor   []string `yaml:"update-minor,flow"`
	UpdatePatch   []string `yaml:"update-patch,flow"`
	IgnoreUnknown bool     `yaml:"ignore-unknown"`
}

VersioningConfig versioning preferences.

Jump to

Keyboard shortcuts

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