Documentation
¶
Overview ¶
Package config provides YAML configuration loading, default branch configs, config merging, and effective configuration resolution for gitsemver.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBranchSpecificTag ¶
GetBranchSpecificTag resolves the pre-release tag for a branch, replacing {BranchName} with the actual branch name (with prefix stripped and special characters replaced with hyphens).
Types ¶
type BranchConfig ¶
type BranchConfig struct {
Regex *string `yaml:"regex"`
Increment *semver.IncrementStrategy `yaml:"increment"`
Mode *semver.VersioningMode `yaml:"mode"`
Tag *string `yaml:"tag"`
SourceBranches *[]string `yaml:"source-branches"`
IsSourceBranchFor *[]string `yaml:"is-source-branch-for"`
IsMainline *bool `yaml:"is-mainline"`
IsReleaseBranch *bool `yaml:"is-release-branch"`
TracksReleaseBranches *bool `yaml:"tracks-release-branches"`
PreventIncrementOfMergedBranchVersion *bool `yaml:"prevent-increment-of-merged-branch-version"`
TrackMergeTarget *bool `yaml:"track-merge-target"`
TagNumberPattern *string `yaml:"tag-number-pattern"`
CommitMessageIncrementing *semver.CommitMessageIncrementMode `yaml:"commit-message-incrementing"`
PreReleaseWeight *int `yaml:"pre-release-weight"`
Priority *int `yaml:"priority"`
}
BranchConfig holds per-branch configuration. All fields are pointers to support merge semantics: nil means "not set, inherit from parent".
func (*BranchConfig) MergeTo ¶
func (bc *BranchConfig) MergeTo(target *BranchConfig)
MergeTo copies non-nil fields from bc into target. Used for overlay semantics: user config overrides defaults where specified.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs a Config by layering overrides on top of defaults.
type Config ¶
type Config struct {
Mode *semver.VersioningMode `yaml:"mode"`
TagPrefix *string `yaml:"tag-prefix"`
BaseVersion *string `yaml:"base-version"`
NextVersion *string `yaml:"next-version"`
Increment *semver.IncrementStrategy `yaml:"increment"`
ContinuousDeploymentFallbackTag *string `yaml:"continuous-delivery-fallback-tag"`
CommitMessageIncrementing *semver.CommitMessageIncrementMode `yaml:"commit-message-incrementing"`
CommitMessageConvention *semver.CommitMessageConvention `yaml:"commit-message-convention"`
MajorVersionBumpMessage *string `yaml:"major-version-bump-message"`
MinorVersionBumpMessage *string `yaml:"minor-version-bump-message"`
PatchVersionBumpMessage *string `yaml:"patch-version-bump-message"`
NoBumpMessage *string `yaml:"no-bump-message"`
CommitDateFormat *string `yaml:"commit-date-format"`
UpdateBuildNumber *bool `yaml:"update-build-number"`
TagPreReleaseWeight *int64 `yaml:"tag-pre-release-weight"`
LegacySemVerPadding *int `yaml:"legacy-semver-padding"`
BuildMetaDataPadding *int `yaml:"build-metadata-padding"`
CommitsSinceVersionSourcePadding *int `yaml:"commits-since-version-source-padding"`
MainlineIncrement *semver.MainlineIncrementMode `yaml:"mainline-increment"`
Branches map[string]*BranchConfig `yaml:"branches"`
Ignore IgnoreConfig `yaml:"ignore"`
MergeMessageFormats map[string]string `yaml:"merge-message-formats"`
}
Config is the root configuration for gitsemver. All optional fields are pointers to support merge semantics during configuration building.
func CreateDefaultConfiguration ¶
func CreateDefaultConfiguration() *Config
CreateDefaultConfiguration returns a Config with all default values populated. This includes 8 branch configurations: main, develop, release, feature, hotfix, pull-request, support, and unknown (catch-all).
func LoadFromBytes ¶
LoadFromBytes parses gitsemver configuration from raw YAML bytes.
func LoadFromFile ¶
LoadFromFile reads and parses a gitsemver configuration file.
func (*Config) GetBranchConfiguration ¶
func (cfg *Config) GetBranchConfiguration(branchName string) (*BranchConfig, string, error)
GetBranchConfiguration returns the best-matching BranchConfig for the given branch name, using priority-ordered regex matching. Returns the matched BranchConfig, the branch config key name, and any error.
func (*Config) GetReleaseBranchConfig ¶
func (cfg *Config) GetReleaseBranchConfig() map[string]*BranchConfig
GetReleaseBranchConfig returns all branch configurations where IsReleaseBranch is true.
func (*Config) IsReleaseBranch ¶
IsReleaseBranch returns true if the given branch name matches any branch configuration where IsReleaseBranch is true.
type EffectiveConfiguration ¶
type EffectiveConfiguration struct {
// Global fields
Mode semver.VersioningMode
TagPrefix string
BaseVersion string
NextVersion string
Increment semver.IncrementStrategy
ContinuousDeploymentFallbackTag string
CommitMessageIncrementing semver.CommitMessageIncrementMode
CommitMessageConvention semver.CommitMessageConvention
MajorVersionBumpMessage string
MinorVersionBumpMessage string
PatchVersionBumpMessage string
NoBumpMessage string
CommitDateFormat string
UpdateBuildNumber bool
TagPreReleaseWeight int64
LegacySemVerPadding int
BuildMetaDataPadding int
CommitsSinceVersionSourcePadding int
MainlineIncrement semver.MainlineIncrementMode
// Branch-specific fields
BranchRegex string
BranchIncrement semver.IncrementStrategy
BranchMode semver.VersioningMode
Tag string
SourceBranches []string
IsMainline bool
IsReleaseBranch bool
TracksReleaseBranches bool
PreventIncrementOfMergedBranchVersion bool
TrackMergeTarget bool
TagNumberPattern string
BranchCommitMessageIncrementing semver.CommitMessageIncrementMode
PreReleaseWeight int
Priority int
// Ignore config
IgnoreCommitsBefore *time.Time
IgnoreSha []string
MergeMessageFormats map[string]string
}
EffectiveConfiguration is a fully resolved configuration with all fields guaranteed to have values. Created from a Config and a specific BranchConfig.
func NewEffectiveConfiguration ¶
func NewEffectiveConfiguration(cfg *Config, branch *BranchConfig) EffectiveConfiguration
NewEffectiveConfiguration creates an EffectiveConfiguration by resolving all pointer fields from the given Config and BranchConfig to concrete values.
type IgnoreConfig ¶
type IgnoreConfig struct {
CommitsBefore *time.Time `yaml:"commits-before"`
Sha []string `yaml:"sha"`
}
IgnoreConfig controls which commits are excluded from version calculation.
func (IgnoreConfig) IsEmpty ¶
func (c IgnoreConfig) IsEmpty() bool
IsEmpty returns true when no ignore rules are configured.
func (*IgnoreConfig) UnmarshalYAML ¶
func (c *IgnoreConfig) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements custom date parsing for IgnoreConfig.