config

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubFiles       string = "{files}"
	SubAllFiles    string = "{all_files}"
	SubStagedFiles string = "{staged_files}"
	SubPushFiles   string = "{push_files}"
)
View Source
const (
	DefaultConfigName     = "lefthook.yml"
	DefaultSourceDir      = ".lefthook"
	DefaultSourceDirLocal = ".lefthook-local"
)
View Source
const CMD = "{cmd}"
View Source
const ChecksumFileName = "lefthook.checksum"

ChecksumFileName - the file, which is used just to store the current config checksum version.

View Source
const GhostHookName = "prepare-commit-msg"

GhostHookName - the hook which logs are not shown and which is used for synchronizing hooks.

Variables

View Source
var (
	LocalConfigNames = []string{"lefthook-local", ".lefthook-local", filepath.Join(".config", "lefthook-local")}
	MainConfigNames  = []string{"lefthook", ".lefthook", filepath.Join(".config", "lefthook")}
)
View Source
var AvailableHooks = map[string]struct{}{
	"applypatch-msg":        {},
	"pre-applypatch":        {},
	"post-applypatch":       {},
	"pre-commit":            {},
	"pre-merge-commit":      {},
	"prepare-commit-msg":    {},
	"commit-msg":            {},
	"post-commit":           {},
	"pre-rebase":            {},
	"post-checkout":         {},
	"post-merge":            {},
	"pre-push":              {},
	"pre-receive":           {},
	"update":                {},
	"proc-receive":          {},
	"post-receive":          {},
	"post-update":           {},
	"reference-transaction": {},
	"push-to-checkout":      {},
	"pre-auto-gc":           {},
	"post-rewrite":          {},
	"sendemail-validate":    {},
	"fsmonitor-watchman":    {},
	"p4-changelist":         {},
	"p4-prepare-changelist": {},
	"p4-post-changelist":    {},
	"p4-pre-submit":         {},
	"post-index-change":     {},
}

AvailableHooks - list of hooks taken from https://git-scm.com/docs/githooks. Keep the order of the hooks same here for easy syncing.

View Source
var ErrFilesIncompatible = errors.New("one of your runners contains incompatible file types")
View Source
var JsonSchema []byte

Functions

func HookUsesPushFiles

func HookUsesPushFiles(hook string) bool

func HookUsesStagedFiles

func HookUsesStagedFiles(hook string) bool

func IsRunFilesCompatible

func IsRunFilesCompatible(run string) bool

func KnownHook

func KnownHook(hook string) bool

func LoadKoanf

func LoadKoanf(filesystem afero.Fs, repo *git.Repository) (*koanf.Koanf, *koanf.Koanf, error)

func NewSkipChecker

func NewSkipChecker(cmd system.Command) *skipChecker

Types

type Command

type Command struct {
	Run      string `json:"run"                 mapstructure:"run"   toml:"run"               yaml:"run"`
	Files    string `json:"files,omitempty"     mapstructure:"files" toml:"files,omitempty"   yaml:",omitempty"`
	Root     string `json:"root,omitempty"      mapstructure:"root"  toml:"root,omitempty"    yaml:",omitempty"`
	FailText string `` /* 126-byte string literal not displayed */

	Skip any `` /* 126-byte string literal not displayed */
	Only any `` /* 126-byte string literal not displayed */

	Tags      []string `` /* 136-byte string literal not displayed */
	FileTypes []string `` /* 146-byte string literal not displayed */
	Glob      []string `` /* 136-byte string literal not displayed */
	Exclude   []string `` /* 136-byte string literal not displayed */

	Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"`

	Priority    int  `json:"priority,omitempty"    mapstructure:"priority"    toml:"priority,omitempty"    yaml:",omitempty"`
	Interactive bool `json:"interactive,omitempty" mapstructure:"interactive" toml:"interactive,omitempty" yaml:",omitempty"`
	UseStdin    bool `` /* 140-byte string literal not displayed */
	StageFixed  bool `` /* 142-byte string literal not displayed */
}

type Config

type Config struct {
	MinVersion string `` /* 160-byte string literal not displayed */

	Lefthook string `json:"lefthook,omitempty" jsonschema:"description=Lefthook executable path or command" mapstructure:"lefthook,omitempty"`

	SourceDir string `` /* 255-byte string literal not displayed */

	SourceDirLocal string `` /* 212-byte string literal not displayed */

	Rc string `json:"rc,omitempty" jsonschema:"description=Provide an rc file - a simple sh script" mapstructure:"rc,omitempty"`

	Output any `` /* 171-byte string literal not displayed */

	Colors any `` /* 177-byte string literal not displayed */

	Extends []string `json:"extends,omitempty" jsonschema:"description=Specify files to extend config with" mapstructure:"extends,omitempty"`

	NoTTY bool `` /* 145-byte string literal not displayed */

	AssertLefthookInstalled bool `` /* 127-byte string literal not displayed */

	SkipLFS bool `` /* 149-byte string literal not displayed */

	GlobMatcher string `` /* 247-byte string literal not displayed */

	Remotes []*Remote `` /* 249-byte string literal not displayed */

	Templates map[string]string `` /* 137-byte string literal not displayed */

	Hooks map[string]*Hook `jsonschema:"-" mapstructure:"-"`
}

func Load

func Load(filesystem afero.Fs, repo *git.Repository) (*Config, error)

Loads configs from the given directory with extensions.

func (*Config) Dump

func (c *Config) Dump(format DumpFormat, out io.Writer) error

func (*Config) Md5

func (c *Config) Md5() (checksum string, err error)

type ConfigNotFoundError

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

ConfigNotFoundError.

func (ConfigNotFoundError) Error

func (err ConfigNotFoundError) Error() string

type DumpFormat

type DumpFormat int
const (
	YAMLFormat DumpFormat = iota
	TOMLFormat
	JSONFormat
	JSONCompactFormat
)

type Group

type Group struct {
	Root     string `json:"root,omitempty"     mapstructure:"root"     toml:"root,omitempty"     yaml:",omitempty"`
	Parallel bool   `json:"parallel,omitempty" mapstructure:"parallel" toml:"parallel,omitempty" yaml:",omitempty"`
	Piped    bool   `json:"piped,omitempty"    mapstructure:"piped"    toml:"piped,omitempty"    yaml:",omitempty"`
	Jobs     []*Job `json:"jobs"               mapstructure:"jobs"     toml:"jobs"               yaml:"jobs"`
}

type Hook

type Hook struct {
	Name          string   `` /* 224-byte string literal not displayed */
	Parallel      bool     `` /* 169-byte string literal not displayed */
	Piped         bool     `` /* 169-byte string literal not displayed */
	Follow        bool     `` /* 169-byte string literal not displayed */
	FailOnChanges string   `` /* 248-byte string literal not displayed */
	Files         string   `` /* 169-byte string literal not displayed */
	ExcludeTags   []string `` /* 212-byte string literal not displayed */
	Exclude       []string `` /* 207-byte string literal not displayed */
	Skip          any      `` /* 200-byte string literal not displayed */
	Only          any      `` /* 200-byte string literal not displayed */

	Jobs []*Job `json:"jobs,omitempty" mapstructure:"jobs" toml:"jobs,omitempty" yaml:",omitempty"`

	Commands map[string]*Command `json:"commands,omitempty" mapstructure:"-" toml:"commands,omitempty" yaml:",omitempty"`
	Scripts  map[string]*Script  `json:"scripts,omitempty"  mapstructure:"-" toml:"scripts,omitempty"  yaml:",omitempty"`
}

type Job

type Job struct {
	Name     string `json:"name,omitempty"      mapstructure:"name"                       toml:"name,omitempty"    yaml:",omitempty"`
	Run      string `` /* 138-byte string literal not displayed */
	Script   string `` /* 138-byte string literal not displayed */
	Runner   string `json:"runner,omitempty"    mapstructure:"runner"                     toml:"runner,omitempty"  yaml:",omitempty"`
	Args     string `json:"args,omitempty"      mapstructure:"args"                       toml:"args,omitempty"    yaml:",omitempty"`
	Root     string `json:"root,omitempty"      mapstructure:"root"                       toml:"root,omitempty"    yaml:",omitempty"`
	Files    string `json:"files,omitempty"     mapstructure:"files"                      toml:"files,omitempty"   yaml:",omitempty"`
	FailText string `` /* 147-byte string literal not displayed */

	Glob      []string `` /* 136-byte string literal not displayed */
	Exclude   []string `` /* 136-byte string literal not displayed */
	Tags      []string `json:"tags,omitempty"       mapstructure:"tags"                  toml:"tags,omitempty"     yaml:",omitempty"`
	FileTypes []string `` /* 146-byte string literal not displayed */

	Env map[string]string `json:"env,omitempty" mapstructure:"env" toml:"env,omitempty" yaml:",omitempty"`

	Interactive bool `json:"interactive,omitempty" mapstructure:"interactive" toml:"interactive,omitempty" yaml:",omitempty"`
	UseStdin    bool `` /* 140-byte string literal not displayed */
	StageFixed  bool `` /* 142-byte string literal not displayed */

	Skip any `` /* 126-byte string literal not displayed */
	Only any `` /* 126-byte string literal not displayed */

	Group *Group `json:"group,omitempty" jsonschema:"oneof_required=Run a group" mapstructure:"group" toml:"group,omitempty" yaml:",omitempty"`
}

func CommandsToJobs

func CommandsToJobs(commands map[string]*Command) []*Job

func ScriptsToJobs

func ScriptsToJobs(scripts map[string]*Script) []*Job

func (*Job) PrintableName

func (job *Job) PrintableName(id string) string

type Remote

type Remote struct {
	GitURL string `` /* 212-byte string literal not displayed */

	Ref string `` /* 148-byte string literal not displayed */

	Configs []string `` /* 199-byte string literal not displayed */

	Refetch bool `` /* 178-byte string literal not displayed */

	RefetchFrequency string `` /* 239-byte string literal not displayed */
}

func (*Remote) Configured

func (r *Remote) Configured() bool

type Script

type Script struct {
	Runner string `json:"runner,omitempty" mapstructure:"runner" toml:"runner,omitempty" yaml:"runner,omitempty"`
	Args   string `json:"args,omitempty"   mapstructure:"args"   toml:"args,omitempty"   yaml:",omitempty"`

	Skip     any               `` /* 136-byte string literal not displayed */
	Only     any               `` /* 136-byte string literal not displayed */
	Tags     []string          `` /* 136-byte string literal not displayed */
	Env      map[string]string `json:"env,omitempty"      mapstructure:"env"                    toml:"env,omitempty"      yaml:",omitempty"`
	Priority int               `json:"priority,omitempty" mapstructure:"priority"               toml:"priority,omitempty" yaml:",omitempty"`

	FailText    string `` /* 140-byte string literal not displayed */
	Interactive bool   `json:"interactive,omitempty" mapstructure:"interactive" toml:"interactive,omitempty" yaml:",omitempty"`
	UseStdin    bool   `` /* 140-byte string literal not displayed */
	StageFixed  bool   `` /* 142-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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