releasegate

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetReleaseGateFn = func() ReleaseGate {
	return defaultReleaseGate
}

GetReleaseGateFn allows overriding the getter function for testing.

View Source
var RegisterReleaseGateFn = func(rg ReleaseGate) {
	defaultReleaseGate = rg
}

RegisterReleaseGateFn allows overriding the registration function for testing.

Functions

func Register

func Register(cfg *Config)

Register initializes the release gate plugin with the given configuration.

func Unregister

func Unregister()

Unregister removes the release gate plugin.

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.

Jump to

Keyboard shortcuts

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