configuration

package
v0.0.0-...-117ffbb Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GlobalMode = "global"
	LocalMode  = "local"
	RepoMode   = "repo"
)
View Source
var DefaultConfig = `# Documentation {{URL}}

hooks:
  commit-msg:
    rules:
      - type: commit-message
        prefix: '[fisherman]'
`

Functions

func FindConfigFiles

func FindConfigFiles(usr *user.User, cwd string, fs billy.Filesystem) (map[string]string, error)

func GetConfigFolder

func GetConfigFolder(usr *user.User, cwd, mode string) (string, error)

Types

type ExtractVariable

type ExtractVariable struct {
	Variable   string `yaml:"variable"`
	Expression string `yaml:"expression"`
}

type FishermanConfig

type FishermanConfig struct {
	GlobalVariables map[string]any   `yaml:"variables,omitempty"`
	Hooks           HooksConfig      `yaml:"hooks,omitempty"`
	Output          log.OutputConfig `yaml:"output,omitempty"`
	DefaultShell    string           `yaml:"default-shell,omitempty"`
}

func Load

func Load(fs billy.Filesystem, files map[string]string) (*FishermanConfig, error)

type HookConfig

type HookConfig struct {
	StaticVariables  map[string]string
	ExtractVariables []ExtractVariable
	Rules            []Rule
}

func (*HookConfig) Compile

func (c *HookConfig) Compile(global map[string]any) (map[string]any, error)

func (*HookConfig) UnmarshalYAML

func (c *HookConfig) UnmarshalYAML(value *yaml.Node) error

type HooksConfig

type HooksConfig struct {
	ApplypatchMsgHook        *HookConfig `yaml:"applypatch-msg"`
	PreApplypatchHook        *HookConfig `yaml:"pre-applypatch"`
	PostApplypatchHook       *HookConfig `yaml:"post-applypatch"`
	PreCommitHook            *HookConfig `yaml:"pre-commit"`
	PreMergeCommitHook       *HookConfig `yaml:"pre-merge-commit"`
	PrepareCommitMsgHook     *HookConfig `yaml:"prepare-commit-msg"`
	CommitMsgHook            *HookConfig `yaml:"commit-msg"`
	PostCommitHook           *HookConfig `yaml:"post-commit"`
	PreRebaseHook            *HookConfig `yaml:"pre-rebase"`
	PostCheckoutHook         *HookConfig `yaml:"post-checkout"`
	PostMergeHook            *HookConfig `yaml:"post-merge"`
	PrePushHook              *HookConfig `yaml:"pre-push"`
	PreReceiveHook           *HookConfig `yaml:"pre-receive"`
	UpdateHook               *HookConfig `yaml:"update"`
	ProcReceiveHook          *HookConfig `yaml:"proc-receive"`
	PostReceiveHook          *HookConfig `yaml:"post-receive"`
	PostUpdateHook           *HookConfig `yaml:"post-update"`
	ReferenceTransactionHook *HookConfig `yaml:"reference-transaction"`
	PushToCheckoutHook       *HookConfig `yaml:"push-to-checkout"`
	PreAutoGcHook            *HookConfig `yaml:"pre-auto-gc"`
	PostRewriteHook          *HookConfig `yaml:"post-rewrite"`
	SendemailValidateHook    *HookConfig `yaml:"sendemail-validate"`
	FsmonitorWatchmanHook    *HookConfig `yaml:"fsmonitor-watchman"`
	P4ChangelistHook         *HookConfig `yaml:"p4-changelist"`
	P4PrepareChangelistHook  *HookConfig `yaml:"p4-prepare-changelist"`
	P4PostChangelistHook     *HookConfig `yaml:"p4-post-changelist"`
	P4PreSubmitHook          *HookConfig `yaml:"p4-pre-submit"`
	PostIndexChangeHook      *HookConfig `yaml:"post-index-change"`
}

type Rule

type Rule interface {
	GetType() string
	GetPrefix() string
	GetCondition() string
	GetPosition() byte
	Check(ctx context.Context, writer io.Writer) error
	Compile(variables map[string]any)
	Configure(options ...rules.RuleOption)
}

Jump to

Keyboard shortcuts

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