config

package
v1.13.6 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 32 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 added in v1.3.6

func HookUsesPushFiles(hook string) bool

func HookUsesStagedFiles added in v1.3.0

func HookUsesStagedFiles(hook string) bool

func IsRunFilesCompatible added in v1.10.0

func IsRunFilesCompatible(run string) bool

func KnownHook added in v1.8.1

func KnownHook(hook string) bool

func LoadKoanf added in v1.10.2

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

func NewSkipChecker added in v1.6.6

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"`

	Skip interface{}       `` /* 127-byte string literal not displayed */
	Only interface{}       `` /* 127-byte string literal not displayed */
	Tags []string          `` /* 127-byte string literal not displayed */
	Env  map[string]string `json:"env,omitempty"  mapstructure:"env"                    toml:"env,omitempty" yaml:",omitempty"`

	FileTypes []string `` /* 128-byte string literal not displayed */

	Glob    []string    `` /* 127-byte string literal not displayed */
	Root    string      `json:"root,omitempty"    mapstructure:"root"                  toml:"root,omitempty"  yaml:",omitempty"`
	Exclude interface{} `` /* 127-byte string literal not displayed */

	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 */
}

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"`

	SkipOutput interface{} `json:"skip_output,omitempty" jsonschema:"oneof_type=boolean;array" koanf:"skip_output" mapstructure:"skip_output,omitempty"`

	Output interface{} `` /* 171-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 */

	Colors interface{} `` /* 177-byte string literal not displayed */

	SkipLFS bool `` /* 149-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 added in v1.4.0

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

func (*Config) Md5 added in v1.8.0

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

type ConfigNotFoundError added in v1.9.0

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

ConfigNotFoundError.

func (ConfigNotFoundError) Error added in v1.9.0

func (err ConfigNotFoundError) Error() string

type DumpFormat added in v1.7.16

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

type Group added in v1.10.0

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      `` /* 212-byte string literal not displayed */
	Parallel      bool        `` /* 157-byte string literal not displayed */
	Piped         bool        `` /* 157-byte string literal not displayed */
	Follow        bool        `` /* 157-byte string literal not displayed */
	FailOnChanges string      `` /* 236-byte string literal not displayed */
	Files         string      `` /* 157-byte string literal not displayed */
	ExcludeTags   []string    `` /* 200-byte string literal not displayed */
	Exclude       []string    `` /* 195-byte string literal not displayed */
	Skip          interface{} `` /* 188-byte string literal not displayed */
	Only          interface{} `` /* 188-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 added in v1.10.0

type Job struct {
	Name   string `json:"name,omitempty"   mapstructure:"name"                       toml:"name,omitempty"   yaml:",omitempty"`
	Run    string `` /* 131-byte string literal not displayed */
	Script string `` /* 131-byte string literal not displayed */
	Runner string `json:"runner,omitempty" mapstructure:"runner"                     toml:"runner,omitempty" yaml:",omitempty"`

	Glob     []string `` /* 133-byte string literal not displayed */
	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   `` /* 142-byte string literal not displayed */

	Tags      []string `json:"tags,omitempty"       mapstructure:"tags" toml:"tags,omitempty"     yaml:",omitempty"`
	FileTypes []string `` /* 129-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 */

	Exclude interface{} `` /* 132-byte string literal not displayed */
	Skip    interface{} `` /* 132-byte string literal not displayed */
	Only    interface{} `` /* 132-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 added in v1.13.0

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

func ScriptsToJobs added in v1.13.0

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

func (*Job) PrintableName added in v1.10.0

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

type Remote added in v1.2.0

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 added in v1.2.0

func (r *Remote) Configured() bool

type Script

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

	Skip     interface{}       `` /* 136-byte string literal not displayed */
	Only     interface{}       `` /* 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