exec

package
v0.0.0-...-6dcb528 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoAllConditionsApply

func DoAllConditionsApply(context *app.Context, conditions []*configuration.Condition, hook string) bool

func DoesAnyConditionApply

func DoesAnyConditionApply(context *app.Context, conditions []*configuration.Condition, hook string) bool

Types

type ActionResult

type ActionResult struct {
	Config      *configuration.Action
	Status      int
	RunErr      error
	DispatchErr error
	Log         *io.CollectorIO
}

ActionResult is the way to communicate the result of an action to the hook runner It contains the action output and errors It also knows if all events where dispatched correctly If you execute actions concurrently the channel is collection action results

func NewActionResult

func NewActionResult(config *configuration.Action, status int, run, dispatch error, log *io.CollectorIO) *ActionResult

type ActionRunner

type ActionRunner struct {
	// contains filtered or unexported fields
}

ActionRunner executes an action Besides executing the action the runner triggers the relevant events

func NewActionRunner

func NewActionRunner(
	appIO io.IO,
	conf *configuration.Configuration,
	repo git.Repo,
	dispatcher *events.Dispatcher,
) *ActionRunner

func (*ActionRunner) Run

func (a *ActionRunner) Run(hook string, action *configuration.Action) *ActionResult

Run executes the action and returns an ActionResult struct

func (*ActionRunner) RunAsync

func (a *ActionRunner) RunAsync(hook string, action *configuration.Action, channel chan *ActionResult)

RunAsync run the action concurrently and send the result to a channel

type ConditionRunner

type ConditionRunner struct {
	// contains filtered or unexported fields
}

ConditionRunner executes conditions If the execution is successful the condition is considered true.

func NewConditionRunner

func NewConditionRunner(cIO io.IO, conf *configuration.Configuration, repo git.Repo) *ConditionRunner

func (*ConditionRunner) Run

func (c *ConditionRunner) Run(hook string, condition *configuration.Condition) bool

Run executes the ConditionRunner

type ConfigInfo

type ConfigInfo struct {
	// contains filtered or unexported fields
}

ConfigInfo blah blah

func NewConfigInfo

func NewConfigInfo(appIO io.IO, config *configuration.Configuration, repo git.Repo) *ConfigInfo

func (*ConfigInfo) Display

func (c *ConfigInfo) Display(what string, show bool)

Display allows to change the displayed details

func (*ConfigInfo) Extended

func (c *ConfigInfo) Extended(ext bool)

Extended gives you an installation status

func (*ConfigInfo) Hook

func (c *ConfigInfo) Hook(hook string)

Hook restricts the info to show only information of given hooks

func (*ConfigInfo) Run

func (c *ConfigInfo) Run() error

type HookRunner

type HookRunner struct {
	// contains filtered or unexported fields
}

HookRunner executes all configured actions for the executed hook

func NewHookRunner

func NewHookRunner(hook string, appIO io.IO, config *configuration.Configuration, repo git.Repo) *HookRunner

func (*HookRunner) Run

func (h *HookRunner) Run() error

Run executes the HookRunner

type Initializer

type Initializer struct {
	// contains filtered or unexported fields
}

Initializer creates an empty CaptainHook configuration file Is used to set up a empty dummy configuration

func NewInitializer

func NewInitializer(appIO io.IO) *Initializer

func (*Initializer) Force

func (i *Initializer) Force(force bool)

Force decides if the configuration file will be overwritten without asking By default this is false but can be changed with the `--force` option.

func (*Initializer) Run

func (i *Initializer) Run() error

Run executes the Initializer

func (*Initializer) UseConfig

func (i *Initializer) UseConfig(config string)

UseConfig sets the path to the configuration file By default this should be `captainhook.json` but can be changed via the --configuration option.

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer is responsible to write the hook files into your local .git/hooks directory Normally it makes sure you don't overwrite your existing git hooks. If you don't want to be bothered to acknowledge every hook you can use the Force function to activate the `force` mode

func NewInstaller

func NewInstaller(appIO io.IO, config *configuration.Configuration, repo git.Repo) *Installer

func (*Installer) EnableBackup

func (i *Installer) EnableBackup(backup bool)

EnableBackup makes sure existing hooks will be moved away to keep a backup

func (*Installer) Force

func (i *Installer) Force(force bool)

Force makes sure to install all hooks without asking any questions

func (*Installer) HookTemplate

func (i *Installer) HookTemplate() string

func (*Installer) OnlyEnabled

func (i *Installer) OnlyEnabled(enabled bool)

OnlyEnabled makes sure you only install hooks that are activated in the configuration

func (*Installer) Run

func (i *Installer) Run() error

func (*Installer) SkipExisting

func (i *Installer) SkipExisting(skip bool)

SkipExisting makes sure you don't overwrite existing hooks

type Uninstaller

type Uninstaller struct {
	// contains filtered or unexported fields
}

Uninstaller is responsible to delete the hook files from your local .git/hooks directory Normally it makes sure to ask for confirmation. If you don't want to be bothered to acknowledge every hook you can use the Force function to activate the `force` mode. If you are unsure use EnableBackup to create a {HOOK-FILE}.bak copy before deletion.

func NewUninstaller

func NewUninstaller(appIO io.IO, config *configuration.Configuration, repo git.Repo) *Uninstaller

func (*Uninstaller) EnableBackup

func (u *Uninstaller) EnableBackup(backup bool)

EnableBackup makes sure existing hooks will be moved away to keep a backup

func (*Uninstaller) Force

func (u *Uninstaller) Force(force bool)

Force makes sure to remove all hooks without asking any questions

func (*Uninstaller) Run

func (u *Uninstaller) Run() error

Run execute the Uninstaller

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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