config

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 29 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 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.

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

func KnownHook(hook string) bool

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{}       `json:"skip,omitempty" mapstructure:"skip" toml:"skip,omitempty,inline" yaml:",omitempty"`
	Only interface{}       `json:"only,omitempty" mapstructure:"only" toml:"only,omitempty,inline" yaml:",omitempty"`
	Tags []string          `json:"tags,omitempty" mapstructure:"tags" toml:"tags,omitempty"        yaml:",omitempty"`
	Env  map[string]string `json:"env,omitempty"  mapstructure:"env"  toml:"env,omitempty"         yaml:",omitempty"`

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

	Glob    string      `json:"glob,omitempty"    mapstructure:"glob"    toml:"glob,omitempty"    yaml:",omitempty"`
	Root    string      `json:"root,omitempty"    mapstructure:"root"    toml:"root,omitempty"    yaml:",omitempty"`
	Exclude interface{} `json:"exclude,omitempty" mapstructure:"exclude" toml:"exclude,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   `json:"use_stdin,omitempty"   mapstructure:"use_stdin"   toml:"use_stdin,omitempty"   yaml:",omitempty"`
	StageFixed  bool   `` /* 142-byte string literal not displayed */
}

func (Command) DoSkip

func (c Command) DoSkip(state func() git.State) bool

func (Command) ExecutionPriority added in v1.6.8

func (c Command) ExecutionPriority() int

func (Command) Validate

func (c Command) Validate() error

type Config

type Config struct {
	MinVersion              string      `koanf:"min_version"               mapstructure:"min_version,omitempty"`
	SourceDir               string      `koanf:"source_dir"                mapstructure:"source_dir"`
	SourceDirLocal          string      `koanf:"source_dir_local"          mapstructure:"source_dir_local"`
	Rc                      string      `mapstructure:"rc,omitempty"`
	SkipOutput              interface{} `koanf:"skip_output"               mapstructure:"skip_output,omitempty"`
	Output                  interface{} `mapstructure:"output,omitempty"`
	Extends                 []string    `mapstructure:"extends,omitempty"`
	NoTTY                   bool        `koanf:"no_tty"                    mapstructure:"no_tty,omitempty"`
	AssertLefthookInstalled bool        `koanf:"assert_lefthook_installed" mapstructure:"assert_lefthook_installed,omitempty"`
	Colors                  interface{} `mapstructure:"colors,omitempty"`
	SkipLFS                 bool        `koanf:"skip_lfs"                  mapstructure:"skip_lfs,omitempty"`

	// Deprecated: use Remotes
	Remote  *Remote   `mapstructure:"remote,omitempty"`
	Remotes []*Remote `mapstructure:"remotes,omitempty"`

	Hooks map[string]*Hook `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)

func (*Config) Validate

func (c *Config) Validate() 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 Hook

type Hook struct {
	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"`

	Files       string      `json:"files,omitempty"        mapstructure:"files"    toml:"files,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"`
	Follow      bool        `json:"follow,omitempty"       mapstructure:"follow"   toml:"follow,omitempty"      yaml:",omitempty"`
	ExcludeTags []string    `` /* 142-byte string literal not displayed */
	Skip        interface{} `json:"skip,omitempty"         mapstructure:"skip"     toml:"skip,omitempty,inline" yaml:",omitempty"`
	Only        interface{} `json:"only,omitempty"         mapstructure:"only"     toml:"only,omitempty,inline" yaml:",omitempty"`
}

func (*Hook) DoSkip added in v1.2.2

func (h *Hook) DoSkip(state func() git.State) bool

func (*Hook) Validate

func (h *Hook) Validate() error

type Remote added in v1.2.0

type Remote struct {
	GitURL string `json:"git_url,omitempty" koanf:"git_url"              mapstructure:"git_url" toml:"git_url"    yaml:"git_url"`
	Ref    string `json:"ref,omitempty"     mapstructure:"ref,omitempty" toml:"ref,omitempty"   yaml:",omitempty"`
	// Deprecated
	Config           string   `` /* 128-byte string literal not displayed */
	Configs          []string `` /* 128-byte string literal not displayed */
	Refetch          bool     `` /* 128-byte string literal not displayed */
	RefetchFrequency string   `` /* 163-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" mapstructure:"runner" toml:"runner" yaml:"runner"`

	Skip     interface{}       `json:"skip,omitempty"     mapstructure:"skip"     toml:"skip,omitempty,inline" yaml:",omitempty"`
	Only     interface{}       `json:"only,omitempty"     mapstructure:"only"     toml:"only,omitempty,inline" yaml:",omitempty"`
	Tags     []string          `json:"tags,omitempty"     mapstructure:"tags"     toml:"tags,omitempty"        yaml:",omitempty"`
	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 `json:"fail_text,omitempty"   mapstructure:"fail_text"   toml:"fail_text,omitempty"   yaml:"fail_text,omitempty"`
	Interactive bool   `json:"interactive,omitempty" mapstructure:"interactive" toml:"interactive,omitempty" yaml:",omitempty"`
	UseStdin    bool   `json:"use_stdin,omitempty"   mapstructure:"use_stdin"   toml:"use_stdin,omitempty"   yaml:",omitempty"`
	StageFixed  bool   `json:"stage_fixed,omitempty" mapstructure:"stage_fixed" toml:"stage_fixed,omitempty" yaml:"stage_fixed,omitempty"`
}

func (Script) DoSkip

func (s Script) DoSkip(state func() git.State) bool

func (Script) ExecutionPriority added in v1.6.8

func (s Script) ExecutionPriority() int

Jump to

Keyboard shortcuts

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