versionvalidator

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled bool   `yaml:"enabled"`
	Rules   []Rule `yaml:"rules,omitempty"`
}

Config holds the configuration for the version validator plugin.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for the version validator.

type GetCurrentBranchFunc added in v0.12.1

type GetCurrentBranchFunc func(ctx context.Context) (string, error)

VersionValidatorPlugin implements the VersionValidator interface. GetCurrentBranchFunc is the function signature for getting the current git branch.

type OSGitBranchReader

type OSGitBranchReader struct{}

OSGitBranchReader implements core.GitBranchReader using actual git commands.

func NewOSGitBranchReader

func NewOSGitBranchReader() *OSGitBranchReader

NewOSGitBranchReader creates a new OSGitBranchReader.

func (*OSGitBranchReader) GetCurrentBranch

func (g *OSGitBranchReader) GetCurrentBranch(ctx context.Context) (string, error)

GetCurrentBranch returns the current git branch name.

type Rule

type Rule struct {
	Type    RuleType `yaml:"type"`
	Pattern string   `yaml:"pattern,omitempty"`
	Value   int      `yaml:"value,omitempty"`
	Enabled bool     `yaml:"enabled,omitempty"`
	Branch  string   `yaml:"branch,omitempty"`
	Allowed []string `yaml:"allowed,omitempty"`
}

Rule represents a single validation rule.

type RuleType

type RuleType string

RuleType defines the type of validation rule.

const (
	RulePreReleaseFormat    RuleType = "pre-release-format"
	RuleMajorVersionMax     RuleType = "major-version-max"
	RuleMinorVersionMax     RuleType = "minor-version-max"
	RulePatchVersionMax     RuleType = "patch-version-max"
	RuleRequirePreRelease0x RuleType = "require-pre-release-for-0x"
	RuleBranchConstraint    RuleType = "branch-constraint"
	RuleNoMajorBump         RuleType = "no-major-bump"
	RuleNoMinorBump         RuleType = "no-minor-bump"
	RuleNoPatchBump         RuleType = "no-patch-bump"
	RuleMaxPreReleaseIter   RuleType = "max-prerelease-iterations"
	RuleRequireEvenMinor    RuleType = "require-even-minor"
)

type VersionValidator

type VersionValidator interface {
	Name() string
	Description() string
	Version() string
	Validate(newVersion, previousVersion semver.SemVersion, bumpType string) error
	ValidateSet(version semver.SemVersion) error
	IsEnabled() bool
}

VersionValidator defines the interface for version validation plugins.

type VersionValidatorPlugin

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

VersionValidatorPlugin implements VersionValidator.

func NewVersionValidator

func NewVersionValidator(cfg *Config) *VersionValidatorPlugin

NewVersionValidator creates a new VersionValidatorPlugin instance.

func (*VersionValidatorPlugin) Description

func (p *VersionValidatorPlugin) Description() string

Description returns a brief description of the plugin.

func (*VersionValidatorPlugin) GetConfig

func (p *VersionValidatorPlugin) GetConfig() *Config

GetConfig returns the plugin configuration.

func (*VersionValidatorPlugin) IsEnabled

func (p *VersionValidatorPlugin) IsEnabled() bool

IsEnabled returns true if the plugin is enabled.

func (*VersionValidatorPlugin) Name

func (p *VersionValidatorPlugin) Name() string

Name returns the plugin name.

func (*VersionValidatorPlugin) Validate

func (p *VersionValidatorPlugin) Validate(newVersion, previousVersion semver.SemVersion, bumpType string) error

Validate checks if the version transition is valid according to configured rules.

func (*VersionValidatorPlugin) ValidateSet

func (p *VersionValidatorPlugin) ValidateSet(version semver.SemVersion) error

ValidateSet checks if a manually set version is valid according to configured rules.

func (*VersionValidatorPlugin) Version

func (p *VersionValidatorPlugin) Version() string

Version returns the plugin version.

Jump to

Keyboard shortcuts

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