Documentation
¶
Index ¶
- Constants
- Variables
- func CheckVersionFile(versionFile string) bool
- func Finish(branch Branch, projectPath string) error
- func Log(message ...any)
- func RegisterFallbackPlugin(plugin Plugin)
- func RegisterPlugin(plugin Plugin)
- func Start(branch Branch, projectPath string) error
- func ValidateToolsAvailability(tools ...string) error
- type Branch
- type CheckoutStrategy
- type ConflictMap
- type HookFunction
- type HookRegistry
- type HookType
- type Logging
- type MergeType
- type Plugin
- type Plugins
- type Repository
- type Version
- type VersionIncrement
Constants ¶
const ( Git = "git" Remote = "origin" )
Tools and names required for the workflow automation commands.
Variables ¶
var GlobalHooks = NewHookRegistry()
GlobalHooks is the global hook registry
var HotfixFinishHooks = struct { AfterMergeIntoDevelopmentHook HookType }{ AfterMergeIntoDevelopmentHook: "HotfixFinish_AfterMergeIntoDevelopmentHook", }
HotfixFinishHooks groups all hooks for the HotfixFinish workflow
var HotfixStartHooks = struct { BeforeHotfixStartHook HookType }{ BeforeHotfixStartHook: "HotfixStart_BeforeHotfixStartHook", }
HotfixStartHooks groups all hooks for the HotfixStart workflow
var ProjectPath = "."
ProjectPath holds the path to the Git repository
var ReleaseStartHooks = struct { BeforeReleaseStartHook HookType AfterUpdateProjectVersionHook HookType }{ BeforeReleaseStartHook: "ReleaseStart_BeforeReleaseStartHook", AfterUpdateProjectVersionHook: "ReleaseStart_AfterUpdateProjectVersionHook", }
ReleaseStartHooks groups all hooks for the ReleaseStart workflow
Functions ¶
func CheckVersionFile ¶
CheckVersionFile checks if version file is found
func Log ¶
func Log(message ...any)
Log a message to Go standard logging based on logging flags and variadic arguments.
func RegisterFallbackPlugin ¶
func RegisterFallbackPlugin(plugin Plugin)
RegisterFallbackPlugin RegisterPlugin adds a fallback plugin
func RegisterPlugin ¶
func RegisterPlugin(plugin Plugin)
RegisterPlugin adds a plugin to the global list of all registered plugins.
func ValidateToolsAvailability ¶
ValidateToolsAvailability Check if some tools are available in the system.
Types ¶
type Branch ¶
type Branch int
Branch represents branch types in the Gitflow model.
const ( Production Branch Development Release Hotfix )
Branch types for the Gitflow model on which the workflow automation commands operate.
type ConflictMap ¶ added in v1.2.0
type HookFunction ¶
type HookFunction func(repository Repository) error
HookFunction is the signature for hook functions
type HookRegistry ¶
type HookRegistry struct {
// contains filtered or unexported fields
}
HookRegistry manages the registration and execution of hooks
func NewHookRegistry ¶
func NewHookRegistry() *HookRegistry
NewHookRegistry creates a new hook registry
func (*HookRegistry) ExecuteHook ¶
func (r *HookRegistry) ExecuteHook(plugin Plugin, hookType HookType, repository Repository) error
ExecuteHook runs a hook if it is registered for the specified plugin
func (*HookRegistry) RegisterHook ¶
func (r *HookRegistry) RegisterHook(pluginName string, hookType HookType, hookFunction HookFunction)
RegisterHook registers a hook callback for a specific hook type
type Logging ¶
type Logging int
Logging controls logging behavior for all repository operations.
const ( Off Logging StdErr StdOut CmdLine Output )
Logging bit flags for controlling logging behavior for all repository operations.
type MergeType ¶
type MergeType int
MergeType represents merge types for repository merging operations.
const ( Squash MergeType NoFastForward FastForward )
Merge types for repository merging operations.
type Plugin ¶
type Plugin interface {
// VersionFileName returns the name of the file that contains the version information in the project.
// For example: "pom.xml" for Maven, etc.
VersionFileName() string
// VersionQualifier returns the suffix that is appended to SNAPSHOT versions.
// For example: "SNAPSHOT" for Maven, etc.
VersionQualifier() string
// RequiredTools returns a list of command-line tools needed to run the plugin.
RequiredTools() []string
// ReadVersion reads the current version from the project file.
ReadVersion(repository Repository) (Version, error)
// WriteVersion writes the provided version to the project file.
WriteVersion(repository Repository, version Version) error
// Stringer returns the human-readable name of the plugin.
fmt.Stringer
}
Plugin is the fundamental interface that must be implemented by all workflow automation plugins.
type Repository ¶
type Repository interface {
Local() string
IsClean() error
HasBranch(branch Branch) (bool, []string, error)
CheckoutBranch(branchName string) error
CheckoutFile(fileName string, strategy CheckoutStrategy) error
ContinueMerge() error
GetMergeConflicts() (map[string][]ConflictMap, error)
CreateBranch(branchName string) error
MergeBranch(branchName string, mergeType MergeType) error
PullBranch(branchName string) error
DeleteBranch(branchName string) error
AddFile(file string) error
CommitChanges(message string) error
TagCommit(tagName string) error
PushChanges(branchName string) error
PushAllChanges() error
PushAllTags() error
PushDeletion(branchName string) error
UndoAllChanges(cause error) error
CompareFiles(sourceBranch, targetBranch, sourceFile, targetFile string) (bool, error)
WriteFile(fileName string, fileContent string) error
}
Repository represents a git repository.
func NewRepository ¶
func NewRepository(projectPath, remote string) Repository
NewRepository enables access to a version control system repository.
type Version ¶
type Version struct {
VersionIncrement VersionIncrement
Major, Minor, Incremental, Qualifier string
}
Version represents a version-stamp with a major, minor, incremental part, and optionally empty qualifier.
var NoVersion Version
NoVersion is the default version without any parts.
func NewVersion ¶
NewVersion Create new version with major, minor, incremental, and qualifier.
func ParseVersion ¶
ParseVersion Parse a version string with major, minor, incremental, and optional qualifier.
func (Version) AddQualifier ¶
AddQualifier Add a qualifier to the version.
func (Version) BranchName ¶
BranchName Create a branch name with a specific version and branch type.
func (Version) Next ¶
func (v Version) Next(increment VersionIncrement) (Version, error)
Next Determine the next version based on the current version and the version increment type.
func (Version) RemoveQualifier ¶
RemoveQualifier Remove the qualifier from the version.
type VersionIncrement ¶
type VersionIncrement int
VersionIncrement Type of version increment.
const ( None VersionIncrement = iota Major Minor Incremental )
Version increment types for the workflow automation commands.