Documentation
¶
Index ¶
- Variables
- func DeleteTag(name string) error
- func FormatMessage(template string, data TemplateData) string
- func ListTags(pattern string) ([]string, error)
- func Register(cfg *Config)
- func ResetTagManager()
- type Config
- type MockGitTagOperations
- func (m *MockGitTagOperations) CreateAnnotatedTag(name, message string) error
- func (m *MockGitTagOperations) CreateLightweightTag(name string) error
- func (m *MockGitTagOperations) CreateSignedTag(name, message, keyID string) error
- func (m *MockGitTagOperations) DeleteRemoteTag(name string) error
- func (m *MockGitTagOperations) DeleteTag(name string) error
- func (m *MockGitTagOperations) GetLatestTag() (string, error)
- func (m *MockGitTagOperations) ListTags(pattern string) ([]string, error)
- func (m *MockGitTagOperations) PushTag(name string) error
- func (m *MockGitTagOperations) TagExists(name string) (bool, error)
- type OSGitTagOperations
- func (g *OSGitTagOperations) CreateAnnotatedTag(name, message string) error
- func (g *OSGitTagOperations) CreateLightweightTag(name string) error
- func (g *OSGitTagOperations) CreateSignedTag(name, message, keyID string) error
- func (g *OSGitTagOperations) DeleteRemoteTag(name string) error
- func (g *OSGitTagOperations) DeleteTag(name string) error
- func (g *OSGitTagOperations) GetLatestTag() (string, error)
- func (g *OSGitTagOperations) ListTags(pattern string) ([]string, error)
- func (g *OSGitTagOperations) PushTag(name string) error
- func (g *OSGitTagOperations) TagExists(name string) (bool, error)
- type TagManager
- type TagManagerPlugin
- func (p *TagManagerPlugin) CreateTag(version semver.SemVersion, message string) error
- func (p *TagManagerPlugin) Description() string
- func (p *TagManagerPlugin) FormatTagMessage(version semver.SemVersion) string
- func (p *TagManagerPlugin) FormatTagName(version semver.SemVersion) string
- func (p *TagManagerPlugin) GetConfig() *Config
- func (p *TagManagerPlugin) GetLatestTag() (semver.SemVersion, error)
- func (p *TagManagerPlugin) IsEnabled() bool
- func (p *TagManagerPlugin) Name() string
- func (p *TagManagerPlugin) ShouldCreateTag(version semver.SemVersion) bool
- func (p *TagManagerPlugin) TagExists(version semver.SemVersion) (bool, error)
- func (p *TagManagerPlugin) ValidateTagAvailable(version semver.SemVersion) error
- func (p *TagManagerPlugin) Version() string
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
var ( RegisterTagManagerFn = registerTagManager GetTagManagerFn = getTagManager )
var TemplatePlaceholders = []string{
"{version}",
"{tag}",
"{prefix}",
"{date}",
"{major}",
"{minor}",
"{patch}",
"{prerelease}",
"{build}",
}
TemplatePlaceholders defines the available placeholders for message templates.
Functions ¶
func FormatMessage ¶ added in v0.7.0
func FormatMessage(template string, data TemplateData) string
FormatMessage applies template substitution to a message template.
func ListTags ¶
ListTags returns all git tags matching a pattern (package-level convenience function).
func Register ¶
func Register(cfg *Config)
Register registers the tag manager plugin with the given configuration.
func ResetTagManager ¶
func ResetTagManager()
ResetTagManager clears the registered tag manager (for testing).
Types ¶
type Config ¶
type Config struct {
// Enabled controls whether the plugin is active.
Enabled bool
// AutoCreate automatically creates tags after version bumps.
AutoCreate bool
// Prefix is the tag prefix (default: "v").
Prefix string
// Annotate creates annotated tags instead of lightweight tags.
Annotate bool
// Push automatically pushes tags to remote after creation.
Push bool
// TagPrereleases controls whether tags are created for pre-release versions.
// When false, tags are only created for stable releases (major/minor/patch).
// Default: false (opt-in for pre-release tagging).
TagPrereleases bool
// Sign creates GPG-signed tags using git tag -s.
// Requires git to be configured with a GPG signing key.
// Default: false.
Sign bool
// SigningKey specifies the GPG key ID to use for signing.
// If empty, git uses the default signing key from user.signingkey config.
// Only used when Sign is true.
SigningKey string
// MessageTemplate is a template for the tag message.
// Supports placeholders: {version}, {tag}, {prefix}, {date}, {major}, {minor}, {patch}, {prerelease}, {build}
// Default: "Release {version}" for annotated/signed tags.
MessageTemplate string
}
Config holds configuration for the tag manager plugin.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default tag manager configuration.
type MockGitTagOperations ¶ added in v0.7.0
type MockGitTagOperations struct {
CreateAnnotatedTagFn func(name, message string) error
CreateLightweightTagFn func(name string) error
CreateSignedTagFn func(name, message, keyID string) error
TagExistsFn func(name string) (bool, error)
GetLatestTagFn func() (string, error)
PushTagFn func(name string) error
ListTagsFn func(pattern string) ([]string, error)
DeleteTagFn func(name string) error
DeleteRemoteTagFn func(name string) error
}
MockGitTagOperations is a mock implementation of core.GitTagOperations for testing.
func (*MockGitTagOperations) CreateAnnotatedTag ¶ added in v0.7.0
func (m *MockGitTagOperations) CreateAnnotatedTag(name, message string) error
CreateAnnotatedTag implements core.GitTagOperations.
func (*MockGitTagOperations) CreateLightweightTag ¶ added in v0.7.0
func (m *MockGitTagOperations) CreateLightweightTag(name string) error
CreateLightweightTag implements core.GitTagOperations.
func (*MockGitTagOperations) CreateSignedTag ¶ added in v0.7.0
func (m *MockGitTagOperations) CreateSignedTag(name, message, keyID string) error
CreateSignedTag implements core.GitTagOperations.
func (*MockGitTagOperations) DeleteRemoteTag ¶ added in v0.7.0
func (m *MockGitTagOperations) DeleteRemoteTag(name string) error
DeleteRemoteTag implements core.GitTagOperations.
func (*MockGitTagOperations) DeleteTag ¶ added in v0.7.0
func (m *MockGitTagOperations) DeleteTag(name string) error
DeleteTag implements core.GitTagOperations.
func (*MockGitTagOperations) GetLatestTag ¶ added in v0.7.0
func (m *MockGitTagOperations) GetLatestTag() (string, error)
GetLatestTag implements core.GitTagOperations.
func (*MockGitTagOperations) ListTags ¶ added in v0.7.0
func (m *MockGitTagOperations) ListTags(pattern string) ([]string, error)
ListTags implements core.GitTagOperations.
func (*MockGitTagOperations) PushTag ¶ added in v0.7.0
func (m *MockGitTagOperations) PushTag(name string) error
PushTag implements core.GitTagOperations.
type OSGitTagOperations ¶
type OSGitTagOperations struct {
// contains filtered or unexported fields
}
OSGitTagOperations implements core.GitTagOperations using actual git commands.
func NewOSGitTagOperations ¶
func NewOSGitTagOperations() *OSGitTagOperations
NewOSGitTagOperations creates a new OSGitTagOperations with the default exec.Command.
func (*OSGitTagOperations) CreateAnnotatedTag ¶
func (g *OSGitTagOperations) CreateAnnotatedTag(name, message string) error
func (*OSGitTagOperations) CreateLightweightTag ¶
func (g *OSGitTagOperations) CreateLightweightTag(name string) error
func (*OSGitTagOperations) CreateSignedTag ¶ added in v0.7.0
func (g *OSGitTagOperations) CreateSignedTag(name, message, keyID string) error
func (*OSGitTagOperations) DeleteRemoteTag ¶ added in v0.7.0
func (g *OSGitTagOperations) DeleteRemoteTag(name string) error
func (*OSGitTagOperations) DeleteTag ¶ added in v0.7.0
func (g *OSGitTagOperations) DeleteTag(name string) error
func (*OSGitTagOperations) GetLatestTag ¶
func (g *OSGitTagOperations) GetLatestTag() (string, error)
func (*OSGitTagOperations) ListTags ¶ added in v0.7.0
func (g *OSGitTagOperations) ListTags(pattern string) ([]string, error)
func (*OSGitTagOperations) PushTag ¶
func (g *OSGitTagOperations) PushTag(name string) error
type TagManager ¶
type TagManager interface {
Name() string
Description() string
Version() string
// CreateTag creates a git tag for the given version.
CreateTag(version semver.SemVersion, message string) error
// TagExists checks if a tag for the given version already exists.
TagExists(version semver.SemVersion) (bool, error)
// GetLatestTag returns the latest semver tag from git.
GetLatestTag() (semver.SemVersion, error)
// ValidateTagAvailable ensures a tag can be created for the version.
ValidateTagAvailable(version semver.SemVersion) error
// FormatTagName formats a version as a tag name.
FormatTagName(version semver.SemVersion) string
}
TagManager defines the interface for git tag operations.
type TagManagerPlugin ¶
type TagManagerPlugin struct {
// contains filtered or unexported fields
}
TagManagerPlugin implements the TagManager interface.
func NewTagManager ¶
func NewTagManager(cfg *Config) *TagManagerPlugin
NewTagManager creates a new tag manager plugin with the given configuration. Uses the default OSGitTagOperations for git operations.
func NewTagManagerWithOps ¶ added in v0.7.0
func NewTagManagerWithOps(cfg *Config, gitOps core.GitTagOperations) *TagManagerPlugin
NewTagManagerWithOps creates a new tag manager plugin with custom git operations. This constructor enables dependency injection for testing.
func (*TagManagerPlugin) CreateTag ¶
func (p *TagManagerPlugin) CreateTag(version semver.SemVersion, message string) error
CreateTag creates a git tag for the given version.
func (*TagManagerPlugin) Description ¶
func (p *TagManagerPlugin) Description() string
func (*TagManagerPlugin) FormatTagMessage ¶ added in v0.7.0
func (p *TagManagerPlugin) FormatTagMessage(version semver.SemVersion) string
FormatTagMessage formats a tag message using the configured template.
func (*TagManagerPlugin) FormatTagName ¶
func (p *TagManagerPlugin) FormatTagName(version semver.SemVersion) string
FormatTagName formats a version as a tag name using the configured prefix.
func (*TagManagerPlugin) GetConfig ¶
func (p *TagManagerPlugin) GetConfig() *Config
GetConfig returns the plugin configuration.
func (*TagManagerPlugin) GetLatestTag ¶
func (p *TagManagerPlugin) GetLatestTag() (semver.SemVersion, error)
GetLatestTag returns the latest semver tag from git.
func (*TagManagerPlugin) IsEnabled ¶
func (p *TagManagerPlugin) IsEnabled() bool
IsEnabled returns whether auto-create is enabled.
func (*TagManagerPlugin) Name ¶
func (p *TagManagerPlugin) Name() string
func (*TagManagerPlugin) ShouldCreateTag ¶ added in v0.7.0
func (p *TagManagerPlugin) ShouldCreateTag(version semver.SemVersion) bool
ShouldCreateTag determines if a tag should be created for the given version. Returns true if tagging is enabled and either: - The version is a stable release (no pre-release), or - The version is a pre-release and TagPrereleases is true.
func (*TagManagerPlugin) TagExists ¶
func (p *TagManagerPlugin) TagExists(version semver.SemVersion) (bool, error)
TagExists checks if a tag for the given version already exists.
func (*TagManagerPlugin) ValidateTagAvailable ¶
func (p *TagManagerPlugin) ValidateTagAvailable(version semver.SemVersion) error
ValidateTagAvailable ensures a tag can be created for the version.
func (*TagManagerPlugin) Version ¶
func (p *TagManagerPlugin) Version() string
type TemplateData ¶ added in v0.7.0
type TemplateData struct {
Version string
Tag string
Prefix string
Date string
Major string
Minor string
Patch string
PreRelease string
Build string
}
TemplateData holds values for template placeholder substitution.
func NewTemplateData ¶ added in v0.7.0
func NewTemplateData(version semver.SemVersion, prefix string) TemplateData
NewTemplateData creates TemplateData from a version and prefix.