core

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Git    = "git"
	Remote = "origin"
)

Tools and names required for the workflow automation commands.

Variables

View Source
var GlobalHooks = NewHookRegistry()

GlobalHooks is the global hook registry

View Source
var HotfixFinishHooks = struct {
	AfterMergeIntoDevelopmentHook HookType
}{
	AfterMergeIntoDevelopmentHook: "HotfixFinish_AfterMergeIntoDevelopmentHook",
}

HotfixFinishHooks groups all hooks for the HotfixFinish workflow

View Source
var HotfixStartHooks = struct {
	BeforeHotfixStartHook HookType
}{
	BeforeHotfixStartHook: "HotfixStart_BeforeHotfixStartHook",
}

HotfixStartHooks groups all hooks for the HotfixStart workflow

View Source
var ProjectPath = "."

ProjectPath holds the path to the Git repository

View Source
var ReleaseStartHooks = struct {
	BeforeReleaseStartHook        HookType
	AfterUpdateProjectVersionHook HookType
}{
	BeforeReleaseStartHook:        "ReleaseStart_BeforeReleaseStartHook",
	AfterUpdateProjectVersionHook: "ReleaseStart_AfterUpdateProjectVersionHook",
}

ReleaseStartHooks groups all hooks for the ReleaseStart workflow

Functions

func CheckVersionFile

func CheckVersionFile(versionFile string) bool

CheckVersionFile checks if version file is found

func Finish

func Finish(branch Branch, projectPath string) error

Finish executes the first plugin that meets the precondition.

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 Start

func Start(branch Branch, projectPath string) error

Start executes the first plugin that meets the precondition.

func ValidateToolsAvailability

func ValidateToolsAvailability(tools ...string) error

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.

func (Branch) String

func (b Branch) String() string

String representation of a branch type.

type CheckoutStrategy

type CheckoutStrategy int
const (
	Theirs CheckoutStrategy = iota
	Ours
)

type ConflictMap added in v1.2.0

type ConflictMap struct {
	OurVersion   string
	TheirVersion string
}

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 HookType

type HookType string

HookType defines the different hook types

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.

func (Logging) String

func (l Logging) String() string

String representation of a logging flag (only one allowed at a time).

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 Plugins

type Plugins []Plugin

Plugins is the list of all registered 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

func NewVersion(major, minor, incremental string, args ...any) Version

NewVersion Create new version with major, minor, incremental, and qualifier.

func ParseVersion

func ParseVersion(version string) (Version, error)

ParseVersion Parse a version string with major, minor, incremental, and optional qualifier.

func (Version) AddQualifier

func (v Version) AddQualifier(qualifier string) Version

AddQualifier Add a qualifier to the version.

func (Version) BranchName

func (v Version) BranchName(branch Branch) string

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

func (v Version) RemoveQualifier() Version

RemoveQualifier Remove the qualifier from the version.

func (Version) String

func (v Version) String() string

Format a version string with major, minor, incremental, and optionally empty qualifier.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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