Documentation
¶
Overview ¶
Package hooks provides Git hooks management for visionspec.
This package enables automatic validation of specs on git operations: - pre-commit: Lint changed spec files - pre-push: Evaluate specs and check for blockers - commit-msg: Validate commit message references spec
Index ¶
- func FindRepoRoot(startPath string) (string, error)
- func GenerateCustomHook(custom CustomTemplate) string
- func GetTemplate(hookType HookType) string
- func GetTemplateDescription(hookType HookType) string
- type Config
- type CustomTemplate
- type Hook
- type HookStatus
- type HookType
- type InstallResult
- type Manager
- type StatusResult
- type UninstallResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindRepoRoot ¶
FindRepoRoot finds the root of the git repository.
func GenerateCustomHook ¶
func GenerateCustomHook(custom CustomTemplate) string
GenerateCustomHook generates a hook script from a custom template.
func GetTemplate ¶
GetTemplate returns the script template for a hook type.
func GetTemplateDescription ¶
GetTemplateDescription returns a description of what a hook does.
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled" yaml:"enabled"`
HooksDir string `json:"hooks_dir,omitempty" yaml:"hooks_dir,omitempty"`
Hooks map[HookType]Hook `json:"hooks,omitempty" yaml:"hooks,omitempty"`
}
Config holds hooks configuration.
type CustomTemplate ¶
CustomTemplate allows creating a custom hook template.
type Hook ¶
type Hook struct {
Type HookType `json:"type" yaml:"type"`
Enabled bool `json:"enabled" yaml:"enabled"`
Description string `json:"description" yaml:"description"`
Script string `json:"script" yaml:"script"`
}
Hook represents a Git hook configuration.
type HookStatus ¶
type HookStatus struct {
Type HookType `json:"type"`
Installed bool `json:"installed"`
IsVisionSpec bool `json:"is_visionspec"`
Executable bool `json:"executable"`
Error string `json:"error,omitempty"`
}
HookStatus contains the status of a single hook.
type InstallResult ¶
type InstallResult struct {
HooksDir string `json:"hooks_dir"`
Installed []string `json:"installed"`
BackedUp []string `json:"backed_up,omitempty"`
Errors []string `json:"errors,omitempty"`
}
InstallResult contains the result of installing hooks.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles Git hooks operations.
func NewManager ¶
NewManager creates a new hooks manager.
func (*Manager) GitHooksDir ¶
GitHooksDir returns the path to the .git/hooks directory.
func (*Manager) Install ¶
func (m *Manager) Install(hookTypes []HookType) (*InstallResult, error)
Install installs visionspec Git hooks.
func (*Manager) Status ¶
func (m *Manager) Status() (*StatusResult, error)
Status checks the status of installed hooks.
type StatusResult ¶
type StatusResult struct {
HooksDir string `json:"hooks_dir"`
Hooks map[HookType]HookStatus `json:"hooks"`
}
StatusResult contains the status of hooks.
type UninstallResult ¶
type UninstallResult struct {
HooksDir string `json:"hooks_dir"`
Removed []string `json:"removed"`
Restored []string `json:"restored,omitempty"`
Skipped []string `json:"skipped,omitempty"`
Errors []string `json:"errors,omitempty"`
}
UninstallResult contains the result of uninstalling hooks.