config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 11 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 (
	DefaultSourceDir      = ".lefthook"
	DefaultSourceDirLocal = ".lefthook-local"
	DefaultColorsEnabled  = true
)
View Source
const CMD = "{cmd}"
View Source
const ChecksumHookName = "prepare-commit-msg"

ChecksumHookName - git hook, which is used just to store the current config checksum version.

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

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

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

	// DEPRECATED
	Runner string `mapstructure:"runner"`
}

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"`
	MinVersion     string   `mapstructure:"min_version"`
	SkipOutput     []string `mapstructure:"skip_output"`
	SourceDir      string   `mapstructure:"source_dir"`
	SourceDirLocal string   `mapstructure:"source_dir_local"`

	Hooks map[string]*Hook
}

func Load

func Load(fs afero.Fs, path string) (*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"`
}

func (*Hook) Validate

func (h *Hook) Validate() error

type Script

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

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

	// DEPRECATED
	Run string `mapstructure:"run"`
}

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