config

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubFiles       string = "{files}"
	SubAllFiles    string = "{all_files}"
	SubStagedFiles string = "{staged_files}"
	PushFiles      string = "{push_files}"
)
View Source
const (
	DefaultConfigName     = "lefthook.yml"
	DefaultSourceDir      = ".lefthook"
	DefaultSourceDirLocal = ".lefthook-local"
	DefaultColorsEnabled  = true
)
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 = [...]string{
	"pre-applypatch",
	"applypatch-msg",
	"post-applypatch",
	"commit-msg",
	"fsmonitor-watchman",
	"p4-changelist",
	"p4-post-changelist",
	"p4-pre-submit",
	"p4-prepare-changelist",
	"pre-commit",
	"post-commit",
	"pre-receive",
	"proc-receive",
	"post-receive",
	"post-merge",
	"pre-rebase",
	"rebase",
	"update",
	"post-update",
	"post-rewrite",
	"post-checkout",
	"post-index-change",
	"pre-auto-gc",
	"pre-merge-commit",
	"pre-push",
	"prepare-commit-msg",
	"push-to-checkout",
	"reference-transaction",
	"sendemail-validate",
}

AvailableHooks - list of hooks taken from https://git-scm.com/docs/githooks.

Functions

func HookAvailable

func HookAvailable(hook string) bool

func HookUsesPushFiles added in v1.3.6

func HookUsesPushFiles(hook string) bool

func HookUsesStagedFiles added in v1.3.0

func HookUsesStagedFiles(hook string) bool

Types

type Command

type Command struct {
	Run string `mapstructure:"run"`

	Skip  interface{}       `mapstructure:"skip"`
	Tags  []string          `mapstructure:"tags"`
	Glob  string            `mapstructure:"glob"`
	Files string            `mapstructure:"files"`
	Env   map[string]string `mapstructure:"env"`

	Root    string `mapstructure:"root"`
	Exclude string `mapstructure:"exclude"`

	FailText    string `mapstructure:"fail_text"`
	Interactive bool   `mapstructure:"interactive"`
	StageFixed  bool   `mapstructure:"stage_fixed"`
}

func (Command) DoSkip

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

func (Command) Validate

func (c Command) Validate() error

type Config

type Config struct {
	Colors         bool     `mapstructure:"colors"`
	Extends        []string `mapstructure:"extends"`
	Remote         Remote   `mapstructure:"remote"`
	MinVersion     string   `mapstructure:"min_version"`
	SkipOutput     []string `mapstructure:"skip_output"`
	SourceDir      string   `mapstructure:"source_dir"`
	SourceDirLocal string   `mapstructure:"source_dir_local"`
	Rc             string   `mapstructure:"rc"`
	NoTTY          bool     `mapstructure:"no_tty"`

	Hooks map[string]*Hook
}

func Load

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

Loads configs from the given directory with extensions.

func (*Config) Validate

func (c *Config) Validate() error

type Hook

type Hook struct {
	// Should be unmarshalled with `mapstructure:"commands"`
	// But replacing '{cmd}' is still an issue
	// Unmarshaling it manually, so omit auto unmarshaling
	Commands map[string]*Command `mapstructure:"?"`

	// Should be unmarshalled with `mapstructure:"scripts"`
	// But parsing keys with dots in it is still an issue: https://github.com/spf13/viper/issues/324
	// Unmarshaling it manually, so omit auto unmarshaling
	Scripts map[string]*Script `mapstructure:"?"`

	Files       string      `mapstructure:"files"`
	Parallel    bool        `mapstructure:"parallel"`
	Piped       bool        `mapstructure:"piped"`
	ExcludeTags []string    `mapstructure:"exclude_tags"`
	Skip        interface{} `mapstructure:"skip"`
	Follow      bool        `mapstructure:"follow"`
}

func (*Hook) DoSkip added in v1.2.2

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

func (*Hook) Validate

func (h *Hook) Validate() error

type Remote added in v1.2.0

type Remote struct {
	GitURL string `mapstructure:"git_url"`
	Ref    string `mapstructure:"ref"`
	Config string `mapstructure:"config"`
}

func (Remote) Configured added in v1.2.0

func (r Remote) Configured() bool

type Script

type Script struct {
	Runner string `mapstructure:"runner"`

	Skip interface{}       `mapstructure:"skip"`
	Tags []string          `mapstructure:"tags"`
	Env  map[string]string `mapstructure:"env"`

	FailText    string `mapstructure:"fail_text"`
	Interactive bool   `mapstructure:"interactive"`
	StageFixed  bool   `mapstructure:"stage_fixed"`
}

func (Script) DoSkip

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

Jump to

Keyboard shortcuts

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