Documentation
¶
Index ¶
- Variables
- func Register(cfg *Config)
- func Unregister()
- type Config
- type GitOperations
- type MockGitOperations
- type OSGitOperations
- type ReleaseGate
- type ReleaseGatePlugin
- func (p *ReleaseGatePlugin) Description() string
- func (p *ReleaseGatePlugin) GetConfig() *Config
- func (p *ReleaseGatePlugin) IsEnabled() bool
- func (p *ReleaseGatePlugin) Name() string
- func (p *ReleaseGatePlugin) ValidateRelease(newVersion, previousVersion semver.SemVersion, bumpType string) error
- func (p *ReleaseGatePlugin) Version() string
Constants ¶
This section is empty.
Variables ¶
var GetReleaseGateFn = func() ReleaseGate {
return defaultReleaseGate
}
GetReleaseGateFn allows overriding the getter function for testing.
var RegisterReleaseGateFn = func(rg ReleaseGate) {
defaultReleaseGate = rg
}
RegisterReleaseGateFn allows overriding the registration function for testing.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Enabled controls whether the plugin is active.
Enabled bool
// RequireCleanWorktree blocks bumps if git has uncommitted changes.
RequireCleanWorktree bool
// RequireCIPass checks CI status before allowing bumps (disabled by default).
RequireCIPass bool
// BlockedOnWIPCommits blocks if recent commits contain WIP/fixup/squash.
BlockedOnWIPCommits bool
// AllowedBranches lists branches where bumps are allowed (empty = all allowed).
AllowedBranches []string
// BlockedBranches lists branches where bumps are never allowed.
BlockedBranches []string
}
Config holds configuration for the release gate plugin.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default release gate configuration.
type GitOperations ¶ added in v0.7.0
type GitOperations interface {
// IsWorktreeClean checks if the git working tree has uncommitted changes.
IsWorktreeClean() (bool, error)
// GetCurrentBranch retrieves the current git branch name.
GetCurrentBranch() (string, error)
// GetRecentCommits retrieves the last N commit messages.
GetRecentCommits(count int) ([]string, error)
}
GitOperations defines the interface for git operations used by release gate.
type MockGitOperations ¶ added in v0.7.0
type MockGitOperations struct {
IsWorktreeCleanFn func() (bool, error)
GetCurrentBranchFn func() (string, error)
GetRecentCommitsFn func(count int) ([]string, error)
}
MockGitOperations is a mock implementation of GitOperations for testing.
func (*MockGitOperations) GetCurrentBranch ¶ added in v0.7.0
func (m *MockGitOperations) GetCurrentBranch() (string, error)
GetCurrentBranch implements GitOperations.
func (*MockGitOperations) GetRecentCommits ¶ added in v0.7.0
func (m *MockGitOperations) GetRecentCommits(count int) ([]string, error)
GetRecentCommits implements GitOperations.
func (*MockGitOperations) IsWorktreeClean ¶ added in v0.7.0
func (m *MockGitOperations) IsWorktreeClean() (bool, error)
IsWorktreeClean implements GitOperations.
type OSGitOperations ¶ added in v0.7.0
type OSGitOperations struct {
// contains filtered or unexported fields
}
OSGitOperations implements GitOperations using actual git commands.
func NewOSGitOperations ¶ added in v0.7.0
func NewOSGitOperations() *OSGitOperations
NewOSGitOperations creates a new OSGitOperations with the default exec.Command.
func (*OSGitOperations) GetCurrentBranch ¶ added in v0.7.0
func (g *OSGitOperations) GetCurrentBranch() (string, error)
GetCurrentBranch retrieves the current git branch name.
func (*OSGitOperations) GetRecentCommits ¶ added in v0.7.0
func (g *OSGitOperations) GetRecentCommits(count int) ([]string, error)
GetRecentCommits retrieves the last N commit messages.
func (*OSGitOperations) IsWorktreeClean ¶ added in v0.7.0
func (g *OSGitOperations) IsWorktreeClean() (bool, error)
IsWorktreeClean checks if the git working tree has uncommitted changes. Returns true if the working tree is clean (no uncommitted changes).
type ReleaseGate ¶
type ReleaseGate interface {
Name() string
Description() string
Version() string
ValidateRelease(newVersion, previousVersion semver.SemVersion, bumpType string) error
}
ReleaseGate defines the interface for release gate validation.
type ReleaseGatePlugin ¶
type ReleaseGatePlugin struct {
// contains filtered or unexported fields
}
ReleaseGatePlugin implements the ReleaseGate interface.
func NewReleaseGate ¶
func NewReleaseGate(cfg *Config) *ReleaseGatePlugin
NewReleaseGate creates a new ReleaseGatePlugin instance. Uses the default OSGitOperations for git operations.
func NewReleaseGateWithOps ¶ added in v0.7.0
func NewReleaseGateWithOps(cfg *Config, gitOps GitOperations) *ReleaseGatePlugin
NewReleaseGateWithOps creates a new ReleaseGatePlugin with custom git operations. This constructor enables dependency injection for testing.
func (*ReleaseGatePlugin) Description ¶
func (p *ReleaseGatePlugin) Description() string
Description returns a brief description of the plugin.
func (*ReleaseGatePlugin) GetConfig ¶
func (p *ReleaseGatePlugin) GetConfig() *Config
GetConfig returns the plugin configuration.
func (*ReleaseGatePlugin) IsEnabled ¶
func (p *ReleaseGatePlugin) IsEnabled() bool
IsEnabled returns true if the plugin is enabled.
func (*ReleaseGatePlugin) Name ¶
func (p *ReleaseGatePlugin) Name() string
Name returns the plugin name.
func (*ReleaseGatePlugin) ValidateRelease ¶
func (p *ReleaseGatePlugin) ValidateRelease(newVersion, previousVersion semver.SemVersion, bumpType string) error
ValidateRelease checks if a version bump is allowed based on configured gates.
func (*ReleaseGatePlugin) Version ¶
func (p *ReleaseGatePlugin) Version() string
Version returns the plugin version.