hooks

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hooks provides a middleware system for CM operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMInterface

type CMInterface interface {
}

CMInterface defines the interface that hooks need from CM.

type ErrorHook

type ErrorHook interface {
	Hook
	OnError(ctx *HookContext) error
}

ErrorHook executes when an operation fails.

type Hook

type Hook interface {
	Name() string
	Priority() int
	Execute(ctx *HookContext) error
}

Hook defines the interface for all hooks.

type HookContext

type HookContext struct {
	OperationName string
	Parameters    map[string]interface{}
	Results       map[string]interface{}
	Error         error
	CM            CMInterface
	Metadata      map[string]interface{}
}

HookContext provides context for hook execution.

type HookManager

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

HookManager manages hook registration and execution.

func (*HookManager) DisableHook

func (hm *HookManager) DisableHook(_, _ string) error

DisableHook disables a hook by name (placeholder for future implementation).

func (*HookManager) EnableHook

func (hm *HookManager) EnableHook(_, _ string) error

EnableHook enables a hook by name (placeholder for future implementation).

func (*HookManager) ExecuteErrorHooks

func (hm *HookManager) ExecuteErrorHooks(operation string, ctx *HookContext) error

ExecuteErrorHooks executes all error-hooks for a specific operation.

func (*HookManager) ExecutePostHooks

func (hm *HookManager) ExecutePostHooks(operation string, ctx *HookContext) error

ExecutePostHooks executes all post-hooks for a specific operation.

func (*HookManager) ExecutePreHooks

func (hm *HookManager) ExecutePreHooks(operation string, ctx *HookContext) error

ExecutePreHooks executes all pre-hooks for a specific operation.

func (*HookManager) ExecuteWorktreeCheckoutHooks added in v0.22.0

func (hm *HookManager) ExecuteWorktreeCheckoutHooks(operation string, ctx *HookContext) error

ExecuteWorktreeCheckoutHooks executes all worktree checkout hooks for a specific operation.

func (*HookManager) ListHooks

func (hm *HookManager) ListHooks(operation string) ([]Hook, error)

ListHooks lists all hooks for a specific operation.

func (*HookManager) RegisterErrorHook

func (hm *HookManager) RegisterErrorHook(operation string, hook ErrorHook) error

RegisterErrorHook registers an error-hook for a specific operation.

func (*HookManager) RegisterPostHook

func (hm *HookManager) RegisterPostHook(operation string, hook PostHook) error

RegisterPostHook registers a post-hook for a specific operation.

func (*HookManager) RegisterPreHook

func (hm *HookManager) RegisterPreHook(operation string, hook PreHook) error

RegisterPreHook registers a pre-hook for a specific operation.

func (*HookManager) RegisterWorktreeCheckoutHook added in v0.22.0

func (hm *HookManager) RegisterWorktreeCheckoutHook(operation string, hook WorktreeCheckoutHook) error

RegisterWorktreeCheckoutHook registers a worktree checkout hook for a specific operation.

func (*HookManager) RemoveHook

func (hm *HookManager) RemoveHook(operation, hookName string) error

RemoveHook removes a hook by name from a specific operation.

type HookManagerInterface

type HookManagerInterface interface {
	// Hook registration.
	RegisterPreHook(operation string, hook PreHook) error
	RegisterPostHook(operation string, hook PostHook) error
	RegisterErrorHook(operation string, hook ErrorHook) error
	RegisterWorktreeCheckoutHook(operation string, hook WorktreeCheckoutHook) error

	// Hook execution.
	ExecutePreHooks(operation string, ctx *HookContext) error
	ExecutePostHooks(operation string, ctx *HookContext) error
	ExecuteErrorHooks(operation string, ctx *HookContext) error
	ExecuteWorktreeCheckoutHooks(operation string, ctx *HookContext) error

	// Hook management.
	RemoveHook(operation, hookName string) error
	EnableHook(operation, hookName string) error
	DisableHook(operation, hookName string) error
	ListHooks(operation string) ([]Hook, error)
}

HookManagerInterface defines the interface for hook management.

func NewHookManager

func NewHookManager() HookManagerInterface

NewHookManager creates a new HookManager instance.

type PostHook

type PostHook interface {
	Hook
	PostExecute(ctx *HookContext) error
}

PostHook executes after an operation.

type PreHook

type PreHook interface {
	Hook
	PreExecute(ctx *HookContext) error
}

PreHook executes before an operation.

type WorktreeCheckoutHook added in v0.22.0

type WorktreeCheckoutHook interface {
	Hook
	OnWorktreeCheckout(ctx *HookContext) error
}

WorktreeCheckoutHook executes between worktree creation and checkout.

Directories

Path Synopsis
Package defaulthooks provides default hook implementations for the code manager.
Package defaulthooks provides default hook implementations for the code manager.
Package gitcrypt provides git-crypt functionality as a hook for worktree operations.
Package gitcrypt provides git-crypt functionality as a hook for worktree operations.
ide
Package ide provides IDE opening functionality through hooks.
Package ide provides IDE opening functionality through hooks.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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